ProgressDialog

class pygamelib.gfx.ui.ProgressDialog(label=Progress dialog, value=0, maximum=100, width=20, progress_marker='▬', empty_marker=' ', adaptive_width=True, destroy_on_complete=True, config=None)

Bases: pygamelib.gfx.ui.Dialog

ProgressDialog is a progress bar widget as a dialog (or popup). The main difference with a progress bar with borders is that it is automatically rendered on the second pass by the screen object (therefore, is visible on top of other graphical elements ).

This dialog requires external interactions so it is the only dialog widget that does not provide a useful show() implementation. As a matter of fact, show do nothing at all.

ProgressDialog is mainly a label, a box and a ProgressBar bundled together.

__init__(label=Progress dialog, value=0, maximum=100, width=20, progress_marker='▬', empty_marker=' ', adaptive_width=True, destroy_on_complete=True, config=None)

The constructor accepts the following parameters.

Parameters:
  • label (str | base.Text) – A label to display on top of the progress bar.
  • value (int) – The initial value parameter. It represents the progression.
  • maximum (int) – The maximum value held by the progress bar. Any value over the maximum is ignored.
  • width (int) – The width of the progress bar widget (in number of screen cells).
  • progress_marker (pygamelib.gfx.core.Sprixel) – The progress marker is displayed on progression. It is the sprixel that fills the bar. Please see below.
  • empty_marker (pygamelib.gfx.core.Sprixel) – The empty marker is displayed instead of the progress marker when the bar should be empty (when the value is too low to fill the bar for example). Please see below.
  • adaptive_width (bool) – If True, the dialog will automatically adapt to the size of the label.
  • destroy_on_complete – If True, the dialog will remove itself from the screen when complete (i.e: when value == maximum)
  • config (UiConfig) – The configuration object.

Example:

# Create a default progress bar with the default configuration
progress_dial = ProgressDialog(
    "Please wait while I'm doing something super duper important",
    config=UiConfig.instance(),
)
# Place the progress bar in the middle of the screen
screen.place(
    progress_dial, screen.vcenter, screen.hcenter - int(progress_bar.width)
)
for progress in range(progress_dial.maximum + 1):
    # Do something useful
    progress_dial.value = progress
    screen.update()

Methods

__init__([label, value, maximum, width, …]) The constructor accepts the following parameters.
render_to_buffer(buffer, row, column, …) Render the object into a display buffer (not a screen buffer).
show() The show method does nothing in the ProgressDialog.

Attributes

config Get and set the config object (UiConfig).
label Get and set the label of the dialog, it has to be a str or base.Text.
maximum Get and set the maximum possible progress, it has to be an int.
user_input Facility to store and retrieve the user input.
value Get and set the current progress value, it has to be an int.
config

Get and set the config object (UiConfig).

label

Get and set the label of the dialog, it has to be a str or base.Text.

maximum

Get and set the maximum possible progress, it has to be an int.

render_to_buffer(buffer, row, column, buffer_height, buffer_width)

Render the object into a display buffer (not a screen buffer).

This method is automatically called by pygamelib.engine.Screen.render().

Parameters:
  • buffer (numpy.array) – A screen buffer to render the item into.
  • row (int) – The row to render in.
  • column (int) – The column to render in.
  • height (int) – The total height of the display buffer.
  • width (int) – The total width of the display buffer.
show()

The show method does nothing in the ProgressDialog. It is a notable exception and the only dialog widget in the UI module to do that.

user_input

Facility to store and retrieve the user input.

value

Get and set the current progress value, it has to be an int.