Matt G wrote:
The problem is, I can't figure out how to update the gauge from my base
app. The idea is...base app starts process...pops up wxDialog with
gauge in it...then base app periodically updates the gauge value. Right
now, once the dialog opens, it keeps control. Anyway to release it?
The dialog only has control if you call its ShowModal() method. You can create the dialog and display it using dlg.Show(1). You can then progressively Update() the progress bar. There's already a standard wxProgressDialog. I created this class to encapsulate a wxProgressDialog in an even-simpler interface:
class ProgressBar:
def __init__(self, maximum, title, text):
self.dlg = wxProgressDialog(title, text, maximum,
style=wxPD_APP_MODAL|wxPD_AUTO_HIDE)
self.count = 0
self.max = maximum - 1
self.dlg.Raise()
def Tick(self, label=''):
self.count += 1
self.dlg.Update( self.count, label )
return self.count < self.max
def Destroy(self):
self.dlg.Update( self.max, '' ) # this should hide the dialog
self.dlg.Destroy()
def Show(self, flag):
return self.dlg.Show(flag)
With this class, I can do something like the following:
dlg = ProgressBar( len(tasklist), "Progress...",
"Performing %d tasks..." % len(tasklist) )
for task in tasklist:
do_task(task)
dlg.Tick()
dlg.Show(0)
dlg.Destroy()
I've also made it easy to change the text label by passing an optional string to tick(). Note that my call to dlg.Show(0) is probably unnecessary (the dialog should automatically hide itself once its count reaches the maximum count), but it doesn't hurt.
Jeff Shannon
Technician/Programmer
Credit International