10.13. progressObserver

class itom.progressObserver(progressBar=None, label=None, progressMinimum=0, progressMaximum=100)

Creates a progressObserver object.

A progressObserver object can be passed to functions, that might need some time to be finished, such that these functions can regularily report their current progress (as number as well as text) via this progress observer. These reported progress values are then displayed in the passed progressBar and / or label. For more information see also this section: Interruptible filters and progress information.

Target functions, that can make use of this progressObserver can be contained in itom algorithm plugins. However these functions must implement the FilterDefExt interface, which is available from itom 3.3 on. Check the method itom.filterHelp() or the help widget of itom in order to find out whether a filter in an algorithm plugin has this ability.

If a filter accepts a progressObserver, pass this object to the keyword argument _observe of the method itom.filter(). Algorithms, that accept this kind of observer can also use the same observer to interrupt the algorithm once the additional interrupt flag of the observer is set. This flag is either set whenever a Python script execution is interrupted or if a signal of a widget has been emitted that was previously connected to this interrupt flag using the method invokeProgressObserverCancellation().

Parameters
progressBaruiItem, optional

This is an optional handle to a progress bar in any user interface. The minimum requirement is that the given widget has at least a slot ‘setValue(int)’, which is called once this progress observer reports a new progress value (bound between progressMinimum and progressMaximum.

labeluiItem, optional

This argument is very similar to progressBar, however it requires a handle to a label widget or any other widget that has a slot setText(QString). This slot is called whenever the target algorithm for this observer reports a new progress text.

progressMinimumint, optional

Minimum progress value that should be used and reported by the target of this observer.

progressMaximumint, optional

Maximum progress value that should be used and reported by the target of this observer.

Notes

This class wraps the C++ class ito::FunctionCancellationAndObserver.

connect(signalSignature, callableMethod, minRepeatInterval=0)

Connects the signal of the progressObserver with the given callable Python method.

This object of progressObserver wraps an underlying object of the C++ class ito::FunctionCancellationAndObserver, which can emit various signals. Use this method to connect any signal to any callable python method (bounded or unbounded). This method must have the same number of arguments than the signal and the types of the signal definition must be convertable into a python object.

Possible signals are (among others):

  • progressTextChanged(QString) -> emitted when the observed function reports a new progress text,

  • progressValueChanged(int) -> emitted whenever the observed function reports a new progress value,

  • cancellationRequested() -> emitted if a cancellation of the observed function has been requested,

  • resetDone() -> emitted if the progressObserver has been reset.

New in itom 4.1.

Parameters
signalSignaturestr

This must be the valid signature. Possible signatures are: progressTextChanged(QString) or progressValueChanged(int)

callableMethodcallable()

Valid method or function that is called if the signal is emitted. The method must provide one parameter for the string or number argument of the signal.

minRepeatIntervalint, optional

If > 0, the same signal only invokes a slot once within the given interval (in ms). Default: 0 (all signals will invoke the callable Python method.

See also

disconnect
disconnect(signalSignature, callableMethod)

Disconnects a connection which must have been established with exactly the same parameters.

New in itom 4.1.

Parameters
signalSignaturestr

This must be the valid signature (progressTextChanged(QString) or progressValueChanged(int))

callableMethodcallable()

valid method or function, that should not be called any more, if the given signal is emitted.

See also

connect
info(verbose=0)

Prints information about possible signals to the command line.

Parameters
verboseint

0: only signals from the plugin class are printed (default) 1: all signals from all inherited classes are printed

requestCancellation()

Requests the cancellation of the filter.

If this progressObserver is currently passed to an object, filter or algorithm, that can be cancelled, a cancellation request is sent to this object. Calling this method will emit the cancellationRequested() signal.

reset()

Resets this object.

Resets this object and empties the current progress text, resets the current progress value to its minimum and resets the cancellation request. Emits the resetDone signal.

isCancelled

bool : returns True if a cancellation request has been signalled, otherwise False.

progressMaximum

int : Gets the maximum value of the progress.

The maximum progress value is the maximum scalar value that the observed function or algorithm should set as its highest progress value.

progressMinimum

int : Gets the minimum value of the progress.

The minimum progress value is the minimum scalar value that the observed function or algorithm should set as its lowest progress value.

progressText

str : the current progress text

This attribute gives access to the current progress text. When set, the signal progressTextChanged is emitted. It can for instance be connected to a setText slot of a QLabel. The text should inform about the step, the long-running method is currently executing.

progressValue

int : gets or sets the current progress value.

If the current progress value is set, the signal progressValueChanged(int) is emitted. It can for instance be connected to a setValue slot of a QProgressBar. The progressValue will be clipped to progressMinimum and progressMaximum.