An alternative to wx.BusyInfo or an indeterminate progress dialog, it makes use of ActiveBitmap.py
to display a gif image or a list of images, as an animation, rather than use a gauge or simple text
to indicate a delay in processing.
An example 2 second gif of the widget in action:
BusyAnimation_1.0.0.zip (28.2 KB)
You may request that the Busy animation self terminates after a preset number of seconds, terminate it
by calling Stop or the Busy window can simply be closed by the user.
You may request that it watches an external process id and terminate when that process terminates.
[this depends upon having the psutil library loaded]
You may choose to display an elapsed time, an elapsed time and time remaining, just time remaining or nothing, depending on whether the animation is self terminating or not.
Times are displayed in standard format, adjusted for the presence of an element, so hh:mm:ss.ff, mm:ss.ff or ss.ff
i.e. 3662.55 seconds = 01:01:02.55 | 78.55 seconds = 01:18.55 | 10.55 seconds = 10.55
images for use in the animation are either a list of wx.Bitmaps e.g.
images = [wx.Bitmap(‘1.png’),wx.Bitmap(‘2.png’),wx.Bitmap(‘3.png’),]
or a gif image e.g:
images = [‘hourglass.gif’,]
BusyAnimation can be loaded as a module, where you are responsible for handling Yielding to wx.App,
as with any normal long running process or you may call it as a subprocess with the parameters you require and it will run standalone.
subprocess.Popen([sys.executable, ‘BusyAnimation.py’, ‘loading.gif,’, ‘100’, ‘1’, ‘15’, ‘-1’],).pid
subprocess.Popen([sys.executable, ‘BusyAnimation.py’, “1.png, 2.png, 3.png”, ‘100’, ‘1’, ‘15’, ‘-1’],).pid
Obviously, in this mode you cannot interact with it, other than kill it manually.
**** Note: I’m not sure if this subprocess route breaks any fundamental rules, so I’d appreciate any feedback if it does
**** Testing was on Linux only, so using psutil and signal modules may act differently on other platforms
In addition to BusyAnimation.py providing its own demonstration, when run from the command line, the zip contains 5 example programs. (ActiveBitmap.py version 1.2.2 is included)
Written & tested: Linux, Python 3.8.10, wxPython 4.2.1 gtk3 (phoenix) wxWidgets 184.108.40.206, Pillow version 9.5.0, psutil version 5.5.1, ActiveBitmap.py version 1.2.2
The quickest way to test it (in the directory you extract the zip file):
python3 BusyAnimation.py 'progress.gif' 50 2 120 -1 '#474779' '#ffffff' 200 200 -1 200
As usual bugs, comments and insults on a postcard please!