Yes, if I understand your question correctly. Just do this:
dlg = wx.ProgressDialog(title, message, parent,
style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)
dlg.Pulse("My first message")
wx.SafeYield()
... a while later
dlg.Pulse("My second message")
wx.SafeYield()
... a while later
dlg.Pulse("My third message")
wx.SafeYield()
HTH.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
http://thedoomedcity.blogspot.com/
\d
On Thu, Jun 11, 2009 at 11:24 AM, Stefanie Lück wrote:
>
> Thanks!
>
> This I tried but the progress bar dosen't Pulse. Only when it's change to
> the next
>
> dlg.Pulse("My first message")
> wx.SafeYield()
>
> but this may take time and the user might think that the program crashes.
This is because you are doing some long running task in the GUI
thread. If you can separate this task and put it in a separate thread
(which does *not* call any GUI-related code), then you can make your
progress dialog pulse as you wish. For example:
dlg = wx.ProgressDialog(title, message, parent,
style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)
thread = MyLongRunningTask_Thread()
counter = 1
while thread.isAlive():
wx.MilliSleep(300)
dlg.Pulse("Doing computation %d"%counter)
counter += 1
There is a simple example of this usage in a little tool I posted to
the list a week ago, called EventsInStyle, here:
http://xoomer.virgilio.it/infinity77/Zipped/EventsInStyle.py
(or http://xoomer.alice.it/infinity77/Zipped/EventsInStyle.py)
Which basically connect to the internet, read the wxWidgets docs,
formats them and in the meanwhile the progressdialog pulses
independently.
You may also take a look at these Wiki pages:
http://wiki.wxpython.org/LongRunningTasks
http://wiki.wxpython.org/Non-Blocking%20Gui