]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/ProgressDialog.py
log wxChoice events in the same format as wxComboBox ones to make it simpler to compa...
[wxWidgets.git] / wxPython / demo / ProgressDialog.py
CommitLineData
8fa876ca
RD
1# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for wx namespace
4#
5# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net)
6#
7# o wx.ProgressDialog appears to be broken. No abort button
8# and it's not possible to dismiss it otherwise.
9#
10
11import wx
bb0054cd
RD
12
13#---------------------------------------------------------------------------
14
34a544a6
RD
15class TestPanel(wx.Panel):
16 def __init__(self, parent, log):
17 self.log = log
18 wx.Panel.__init__(self, parent, -1)
19
20 b = wx.Button(self, -1, "Create and Show a ProgressDialog", (50,50))
21 self.Bind(wx.EVT_BUTTON, self.OnButton, b)
22
23
24 def OnButton(self, evt):
83c8bcfd 25 max = 80
34a544a6
RD
26
27 dlg = wx.ProgressDialog("Progress dialog example",
28 "An informative message",
29 maximum = max,
30 parent=self,
83c8bcfd
RD
31 style = wx.PD_CAN_ABORT
32 | wx.PD_APP_MODAL
33 | wx.PD_ELAPSED_TIME
34 #| wx.PD_ESTIMATED_TIME
35 | wx.PD_REMAINING_TIME
36 )
bb0054cd 37
34a544a6
RD
38 keepGoing = True
39 count = 0
8fa876ca 40
34a544a6 41 while keepGoing and count < max:
83c8bcfd
RD
42 count += 1
43 wx.MilliSleep(250)
bb0054cd 44
83c8bcfd 45 if count >= max / 2:
34a544a6
RD
46 keepGoing = dlg.Update(count, "Half-time!")
47 else:
48 keepGoing = dlg.Update(count)
bb0054cd 49
34a544a6 50 dlg.Destroy()
bb0054cd 51
34a544a6
RD
52#---------------------------------------------------------------------------
53
54
55def runTest(frame, nb, log):
56 win = TestPanel(nb, log)
57 return win
bb0054cd
RD
58
59#---------------------------------------------------------------------------
60
61
1fded56b 62overview = """\
b4f1aaad 63<html><body>
8fa876ca
RD
64This class represents a dialog that shows a short message and a progress bar.
65Optionally, it can display an ABORT button
b4f1aaad 66<p>
8fa876ca
RD
67This dialog indicates the progress of some event that takes a while to accomplish,
68usually, such as file copy progress, download progress, and so on. The display
69is <b>completely</b> under control of the program; you must update the dialog from
70within the program creating it.
b4f1aaad 71<p>
8fa876ca
RD
72When the dialog closes, you must check to see if the user aborted the process or
73not, and act accordingly -- that is, if the PD_CAN_ABORT style flag is set.
74If not then you may progress blissfully onward.
b4f1aaad 75</body></html>
8fa876ca 76"""
bb0054cd 77
1fded56b
RD
78if __name__ == '__main__':
79 import sys,os
80 import run
8eca4fef 81 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])