[wxPython-users] Auto-pulsing wxProgressDialog?

Chris Mellon arkanes at gmail.com
Wed Jan 3 08:38:55 PST 2007


On 1/3/07, Chris Mellon <arkanes at gmail.com> wrote:
> On 1/3/07, Rooney, Mike (ext. 324) <mxr at qvii.com> wrote:
> > >Recent version of wxPython include a library called
> > >wx.lib.delayedresult which can help with this, it is featured in the
> > >demo under the process and events category.
> >
> > I gave it a shot but the same thing happens. I just don't understand!
> > I replaced the database call with a sleep call just to simplify even
> > more but still no pulsing occurs.
> >
> > Let me post a little code and maybe it will be clear what I am doing
> > wrong. onPack in the controller is what is called first. It tells the
> > view to show the dialog, which is supposed to start a timer but it
> > never pulses and 12 never gets printed.
> >
> > in the controller:
> >     def onPack(self, event=None):
> >                 self.view.showPackDialog()
> >
> >             import time, wx.lib.delayedresult as delayedresult
> >             delayedresult.startWorker(self.onPackDone, lambda:time.sleep(5))
> >
> >     def onPackDone(self, result):
> >                 self.view.closePackDialog()
> >
> >
> > in the view:
> >     def showPackDialog(self):
> >         self.dlg = wx.ProgressDialog("Packing Database", "Packing routines in the ZopeDB", parent=self)
> >         self.t = wx.Timer(self)
> >         self.t.Bind(wx.EVT_TIMER, self.onPackTimer)
> >         self.t.Start(10)
> >
> >     def onPackTimer(self, e):
> >         print 12 #debug
> >         self.dlg.Pulse()
> >
> >     def closePackDialog(self):
> >         self.t.Stop()
> >         self.dlg.Destroy()
> >
> > Thanks for your help so far, it is greatly appreciated. Hopefully the
> > code is clean and easy to interpret (no pun intended).
> >
>
> Call Refresh() after Pulse().
>

Woops, you have a small error in your code ;) It's related to your
timer. You're sending the timer events to the view, but binding the
event handler to the Timer itself. Note "self.t.Bind". Replace with
self.Bind and all is well.

The Refresh() actually isn't needed - my quick one-off code had a
different problem that was requiring a manual refresh.




More information about the wxpython-users mailing list