Hi, all:
recently, I would like to create a Costumed Progressdialog or
kind of waiting dialog. Because I don't need the progress bar, but a
animated gif.
So I use wx.Dialog as the parent class, and the code is as
follows:
import wx
import wx.animate
from threading import *
class Progress_Dialog(wx.Dialog):
def __init__(self, parent, Title, Lable):
wx.Dialog.__init__(self, parent, -1, Title)
ag_fname = "..\\menuicon\\progress.gif"
ag = wx.animate.GIFAnimationCtrl(self, -1, ag_fname)
# clears the background
ag.GetPlayer().UseBackgroundColour(True)
# continuously loop through the frames of the gif file
(default)
ag.Play()
text = wx.StaticText(self, -1, Lable)
size1 = wx.BoxSizer(wx.VERTICAL)
size1.Add(ag, -1, wx.EXPAND)
size1.Add(text,-1, wx.ALIGN_CENTER)
self.SetSizer(size1)
self.Layout()
self.ShowModal()
# Thread class that executes processing
class WorkerThread(Thread):
"""Worker Thread Class."""
def __init__(self, notify_window):
"""Init Worker Thread Class."""
Thread.__init__(self)
self._notify_window = notify_window
# This starts the thread running on creation, but you could
# also make the GUI thread responsible for calling this
self.start()
def run(self):
self._notify_window.progressdialog =
Progress_Dialog(self._notify_window, "progressbox","Time remaining")
So in my opinion, the WorkerThread should generate a Dialog window
which show the animated gif. But in fact, there is an error happened
"PyAssertionError: C++ assertion "wxThread::IsMain()" failed at ..\..
\src\common\timercmn.cpp(66) in wxTimerBase::Start(): timer can only
be started from the main thread"
Does that mean the animated gif only can used in main thread? I am not
sure?!
So the basic question is that how can I develop a Waiting dialog or
progress dialog with an animated gif?