pyreporting.progress.Progress#

class Progress(progress_type, parent=None)[source]#

Bases: object

Handler for a progress bar supporting nested progress reporting

The Reporting class uses this class to display and update_progress a progress bar and associated text. The actual progress bar is created using the ProgressBar object - this object is either passed in directly, or specified as a ProgressBarType enum which is used to construct a suitable ProgressBar object. This allows for a terminal-based or PySide QT dialog, or you can implement your own custom ProgressBar class.

Create Progress object for handling progress bar

Parameters:
  • progress_type – Type of progress bar. Specify one of the ProgressBarType enum to create a standard type of progress bar, or implement your own by providing a factory object implementing ProgressBarFactory

  • parent – For GUI progress bar, the parent object

Methods

advance_progress

Move the progress bar along one stage

check_for_cancel

Raise Cancel exception if user has clicked Cancel in the progress dialog

complete_progress

Complete the current progress dialog.

has_been_cancelled

Return True if the user has clicked Cancel in the progress dialog

reset_progress

Close all progress bars and clear all progress nesting

set_progress_parent

Set the GUI parent window handle for progress dialogs

start_progress

Initialise and show progress dialog reporting.

update_progress

Update values in the progress dialog

update_progress_stage

Update progress for an operation consisting of a set number of stages

advance_progress(step=None, label=None, title=None)[source]#

Move the progress bar along one stage

Unspecified parameters for step, label or title will retain their previous value.

If step has not been specified in this call or in any previous call for this nested progress bar, it will take an inferred value (if one could be computed), otherwise it will be the difference between the current value (0 if unspecified) and 100%

Parameters:
  • step – Percentage difference between progress calls. None to keep current step value

  • label – Text to display in progress bar, or None to keep current or default label

  • title – Title text for the progress dialog, or None to keep current or default title

check_for_cancel()[source]#

Raise Cancel exception if user has clicked Cancel in the progress dialog

complete_progress()[source]#

Complete the current progress dialog. If there are no other progress bars currently nested then hide the dialog, otherwise return to the parent progress and complete the current stage

has_been_cancelled()[source]#

Return True if the user has clicked Cancel in the progress dialog

Return type:

bool

reset_progress()[source]#

Close all progress bars and clear all progress nesting

set_progress_parent(parent)[source]#

Set the GUI parent window handle for progress dialogs

start_progress(value=None, step=None, label=None, title=None)[source]#

Initialise and show progress dialog reporting. If a progress dialog is already visible, creates a nested progress level.

Each start_progress() call must be matched by exactly one complete_progress() call

Parameters:
  • value – Current progress bar value, or set to None for a continuous progress bar (if supported)

  • step – Percentage difference between progress calls. This is used when calling advance_progress() and for correctly updating nested progress calls

  • label – Text to display in progress bar, or None to keep current or default label

  • title – Title text for the progress dialog, or None to keep current or default title

update_progress(value=None, step=None, label=None, title=None)[source]#

Update values in the progress dialog

Unspecified parameters for value, label or title will retain their previous value.

If step is not specified, it will be computed automatically from the difference between previous value updates. The step is used with nested progress (push_progress and pop_progress) so that the range of the nested progress will run between value and value + step

Parameters:
  • value – Current progress bar value, or set to None for a continuous progress bar (if supported)

  • step – Percentage difference between progress calls. Used if using advance_progress() and for correctly updating nested progress calls. Computed automatically when using update_progress_stage

  • label – Text to display in progress bar, or None to keep current or default label

  • title – Title text for the progress dialog, or None to keep current or default title

update_progress_stage(stage, num_stages, label=None, title=None)[source]#

Update progress for an operation consisting of a set number of stages

Specify the total number of stages to be performed and the current stage number. The value and step will be computed automatically

Unspecified parameters for label or title will retain their previous value

Parameters:
  • stage – The index of the current stage

  • num_stages – Total number of stages

  • label – The label text to display by the progress, or None to keep current text

  • title – The title of the progress dialog, or None to keep current text