]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | import wx | |
bb0054cd RD |
12 | |
13 | #--------------------------------------------------------------------------- | |
14 | ||
34a544a6 RD |
15 | class 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): | |
25 | max = 20 | |
26 | ||
27 | dlg = wx.ProgressDialog("Progress dialog example", | |
28 | "An informative message", | |
29 | maximum = max, | |
30 | parent=self, | |
31 | style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL) | |
bb0054cd | 32 | |
34a544a6 RD |
33 | keepGoing = True |
34 | count = 0 | |
8fa876ca | 35 | |
34a544a6 RD |
36 | while keepGoing and count < max: |
37 | count = count + 1 | |
38 | #print count | |
39 | wx.Sleep(1) | |
bb0054cd | 40 | |
34a544a6 RD |
41 | if count == max / 2: |
42 | keepGoing = dlg.Update(count, "Half-time!") | |
43 | else: | |
44 | keepGoing = dlg.Update(count) | |
bb0054cd | 45 | |
34a544a6 | 46 | dlg.Destroy() |
bb0054cd | 47 | |
34a544a6 RD |
48 | #--------------------------------------------------------------------------- |
49 | ||
50 | ||
51 | def runTest(frame, nb, log): | |
52 | win = TestPanel(nb, log) | |
53 | return win | |
bb0054cd RD |
54 | |
55 | #--------------------------------------------------------------------------- | |
56 | ||
57 | ||
1fded56b | 58 | overview = """\ |
b4f1aaad | 59 | <html><body> |
8fa876ca RD |
60 | This class represents a dialog that shows a short message and a progress bar. |
61 | Optionally, it can display an ABORT button | |
b4f1aaad | 62 | <p> |
8fa876ca RD |
63 | This dialog indicates the progress of some event that takes a while to accomplish, |
64 | usually, such as file copy progress, download progress, and so on. The display | |
65 | is <b>completely</b> under control of the program; you must update the dialog from | |
66 | within the program creating it. | |
b4f1aaad | 67 | <p> |
8fa876ca RD |
68 | When the dialog closes, you must check to see if the user aborted the process or |
69 | not, and act accordingly -- that is, if the PD_CAN_ABORT style flag is set. | |
70 | If not then you may progress blissfully onward. | |
b4f1aaad | 71 | </body></html> |
8fa876ca | 72 | """ |
bb0054cd | 73 | |
1fded56b RD |
74 | if __name__ == '__main__': |
75 | import sys,os | |
76 | import run | |
8eca4fef | 77 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |