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 regularly report their current progress (as number as well as text) via this progress observer. These reported progress values are then displayed in the passedprogressBar
and / orlabel
. 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 methoditom.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 methoditom.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 methodinvokeProgressObserverCancellation()
.- Parameters:
- progressBar
uiItem
,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
andprogressMaximum
.- label
uiItem
,optional
This argument is very similar to
progressBar
, however it requires a handle to a label widget or any other widget that has a slotsetText(QString)
. This slot is called whenever the target algorithm for this observer reports a new progress text.- progressMinimum
int
,optional
Minimum progress value that should be used and reported by the target of this observer.
- progressMaximum
int
,optional
Maximum progress value that should be used and reported by the target of this observer.
- progressBar
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++ classito::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 convertible 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:
- signalSignature
str
This must be the valid signature. Possible signatures are:
progressTextChanged(QString)
orprogressValueChanged(int)
- callableMethod
callable()
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.
- minRepeatInterval
int
,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.
- signalSignature
See also
- disconnect(signalSignature, callableMethod)#
Disconnects a connection which must have been established with exactly the same parameters.
New in itom 4.1.
- Parameters:
- signalSignature
str
This must be the valid signature (
progressTextChanged(QString)
orprogressValueChanged(int)
)- callableMethod
callable()
valid method or function, that should not be called any more, if the given signal is emitted.
- signalSignature
See also
- info(verbose=0)#
Prints information about possible signals to the command line.
- Parameters:
- verbose
int
0: only signals from the plugin class are printed (default) 1: all signals from all inherited classes are printed
- verbose
- 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 thecancellationRequested()
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.
- 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 textThis attribute gives access to the current progress text. When set, the signal
progressTextChanged
is emitted. It can for instance be connected to asetText
slot of a QLabel. The text should inform about the step, the long-running method is currently executing.