fsleyes_widgets.utils.progress¶
This module provides some classes and functions which use the
wx.ProgressDialog to display the progress of some task.
-
fsleyes_widgets.utils.progress.bounce(*args, **kwargs)¶ Context manager which creates, starts and yields a
Bouncedialog, and destroys it on exit.
-
fsleyes_widgets.utils.progress.runWithBounce(task, *args, **kwargs)¶ Runs the given
taskin a separate thread, and creates aBouncedialog which is displayed while the task is running.Parameters: - callback – Must be passed as a keyword argument. A function to call
when the
taskhas finished. Must accept one boolean parameter which isTrueif the task ended, orFalseif the progress dialog was cancelled. - dlg – Must be passed as a keyword argument. A
Bouncedialog to use. If not provided, one is created. If provided, the caller is responsible for destroying it. - polltime – Must be passed as a keyword argument. Amount of time in seconds to wait while periodically checking the task state. Defaults to 0.1 seconds.
All other arguments are passed through to
Bounce.__init__(), unless adlgis provided.Note
This function is non-blocking - it returns immediately. Use the
callbackfunction to be notified when thetaskhas completed.- callback – Must be passed as a keyword argument. A function to call
when the
-
class
fsleyes_widgets.utils.progress.Bounce(title=None, message=None, *args, **kwargs)¶ Bases:
wx._core.ProgressDialogDisplay a ‘bouncing’ progress bar.
The
Bounceclass is awx.ProgressDialogfor use with tasks with an unknown duration. The progress bar ‘bounces’ back and forth until the dialog is destroyed or cancelled.A
Bouncedialog can either be controlled manually via theDoBounce()method, , or allowed to run automatically via theStartBounce(). Automatic bouncing can be stopped viaStopBounce().Create a
Bouncedialog.Parameters: - title – Dialog title.
- message – Dialog message.
- delay – Must be passed as a keyword argument. Delay in milliseconds between progress bar updates. Defaults to 200 milliseconds.
- values – Must be passed as a keyword argument. A sequence of
values from 1 to 99 specifying the locations of the
progress bar on each update. Deafults to
[1, 25, 50, 75, 99].
All other arguments are passed through to
wx.ProgressDialog.-
__init__(title=None, message=None, *args, **kwargs)¶ Create a
Bouncedialog.Parameters: - title – Dialog title.
- message – Dialog message.
- delay – Must be passed as a keyword argument. Delay in milliseconds between progress bar updates. Defaults to 200 milliseconds.
- values – Must be passed as a keyword argument. A sequence of
values from 1 to 99 specifying the locations of the
progress bar on each update. Deafults to
[1, 25, 50, 75, 99].
All other arguments are passed through to
wx.ProgressDialog.
-
classmethod
runWithBounce(task, *args, **kwargs)¶ Deprecated - use the standalone
runWithBounce()function instead.
-
Close()¶ Close the
Bouncedialog.
-
EndModal(code=5100)¶ Close the
Bouncedialog.
-
Destroy()¶ Destroy the
Bouncedialog.
-
StartBounce()¶ Start automatic bouncing.
-
StopBounce()¶ Stop automatic bouncing.
-
Update(value, message=None)¶ Overrides
wx.ProgressDialog.Update.The
Updatemethod in wxPython 3.0.2.0 will raise an error if amessageofNonegets passed in. This implementation accepts amessageofNone.
-
UpdateMessage(message)¶ Updates the message displayed on the dialog.
-
DoBounce(message=None)¶ Perform a single bounce update to the progress bar.
Parameters: message – New message to show. Returns: Falseif the dialog gets cancelled,Trueotherwise.
-
_Bounce__autoBounce()¶ Automatic bouncing.
If a call to
StopBounce()has been made, this method does nothing.Otherwise, calls
DoBounce()and, if that call returnsTrue, schedules a future call to this method.
-
__module__= 'fsleyes_widgets.utils.progress'¶