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)[source]
Context manager which creates, starts and yields a
Bounce
dialog, and destroys it on exit.
- fsleyes_widgets.utils.progress.runWithBounce(task, *args, **kwargs)[source]
Runs the given
task
in a separate thread, and creates aBounce
dialog which is displayed while the task is running.- Parameters:
callback – Must be passed as a keyword argument. A function to call when the
task
has finished. Must accept one boolean parameter which isTrue
if the task ended, orFalse
if the progress dialog was cancelled.dlg – Must be passed as a keyword argument. A
Bounce
dialog 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 adlg
is provided.Note
This function is non-blocking - it returns immediately. Use the
callback
function to be notified when thetask
has completed.
- class fsleyes_widgets.utils.progress.Bounce(title=None, message=None, *args, **kwargs)[source]
Bases:
ProgressDialog
Display a ‘bouncing’ progress bar.
The
Bounce
class is awx.ProgressDialog
for use with tasks with an unknown duration. The progress bar ‘bounces’ back and forth until the dialog is destroyed or cancelled.A
Bounce
dialog can either be controlled manually via theDoBounce()
method, , or allowed to run automatically via theStartBounce()
. Automatic bouncing can be stopped viaStopBounce()
.Create a
Bounce
dialog.- 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)[source]
Deprecated - use the standalone
runWithBounce()
function instead.