]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-09/progress_box.py
fixed wxVsnprintf() to write as much as it can if the output buffer is too short
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-09 / progress_box.py
1 import wx
2
3 class Frame(wx.Frame):
4 def __init__(self, parent):
5 wx.Frame.__init__(self, parent, title="ProgressDialog sample")
6 self.progressMax = 100
7 self.count = 0
8 self.dialog = None
9 self.timer = wx.Timer(self)
10 self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
11 self.timer.Start(1000)
12
13 def OnTimer(self, evt):
14 if not self.dialog:
15 self.dialog = wx.ProgressDialog("A progress box", "Time remaining",
16 self.progressMax,
17 style=wx.PD_CAN_ABORT
18 | wx.PD_ELAPSED_TIME
19 | wx.PD_REMAINING_TIME)
20
21 self.count += 1
22 if wx.VERSION < (2,7,1,1):
23 keepGoing = self.dialog.Update(self.count)
24 else:
25 (keepGoing, skip) = self.dialog.Update(self.count)
26 if not keepGoing or self.count == self.progressMax:
27 self.dialog.Destroy()
28 self.timer.Stop()
29
30
31 if __name__ == "__main__":
32 app = wx.PySimpleApp()
33 frame = Frame(None)
34 frame.Show()
35 app.MainLoop()
36