From: Alex T. <al...@tw...> - 2004-06-27 15:41:59
|
At 07:16 23/06/2004 -0700, ralph heimburger wrote: >I created a report interface that when the user presses the "GO" button, >I want to display a "Processing..." message. I think it's basically a >MessageDialog with no buttons and no return values but I can't find how to >do it. I doubt if you should use a MessageDialog - that's really intended for getting input from the user (though you could probably do it). I'd suggest a ProgressDialog - and if it's going to take long enough to be worth putting up a "Processing ..." message, it's probably worth giving some progress info to keep the user satisfied. And in that case, you should consider whether it is feasible, and desirable, to allow the user to abort the processing .... PythonCard doesn't, as far as I know, provide any progress dialog help - but you can simply use the ProgressDialog form wxPython directly. See the wxPython Sample Program (under Common Dialogs). Or, here's a quick sample handler for a "Go" button - in this case it does nothing except count to 30 seconds (this one allows the user to abort, so not quite as simple). > def on_GoButton_mouseClick(self, event): > self.timeToDoIt = 30 > self.dial = wx.wxProgressDialog("Going ...", "Doing what you told > me", \ > self.timeToDoIt, \ > style=wx.wxPD_APP_MODAL|wx.wxPD_AUTO_HIDE|wx.wxPD_CAN_ABORT) > > self.timeRemaining = self.timeToDoIt > self.myTimer = wx.wxTimer(self.components.GoButton, -1) # create > a timer > self.myTimer.Start(1000) # launch timer, to fire every second > > > def on_GoButton_timer(self, event): > # we're being lazy and just leaving the timer running all the time > # so check if any timed action is under way > if self.timeRemaining == 0: return > > self.timeRemaining = self.timeRemaining-1 > print self.timeRemaining > update = self.dial.Update(self.timeToDoIt-self.timeRemaining) > # note - dialog goes away automatically when complete > if not update: > print "User abort with ", self.timeRemaining, "still to go" > self.dial.Destroy() > self.timeRemaining = 0 -- Alex Tweedly |