]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/ProgressDialog.py
Don't decref if the interpreter is not initialized, (eg. it's in its
[wxWidgets.git] / wxPython / demo / ProgressDialog.py
... / ...
CommitLineData
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
12
13#---------------------------------------------------------------------------
14
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):
25 max = 80
26
27 dlg = wx.ProgressDialog("Progress dialog example",
28 "An informative message",
29 maximum = max,
30 parent=self,
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 )
37
38 keepGoing = True
39 count = 0
40
41 while keepGoing and count < max:
42 count += 1
43 wx.MilliSleep(250)
44
45 if count >= max / 2:
46 (keepGoing, skip) = dlg.Update(count, "Half-time!")
47 else:
48 (keepGoing, skip) = dlg.Update(count)
49
50
51 dlg.Destroy()
52
53#---------------------------------------------------------------------------
54
55
56def runTest(frame, nb, log):
57 win = TestPanel(nb, log)
58 return win
59
60#---------------------------------------------------------------------------
61
62
63overview = """\
64<html><body>
65This class represents a dialog that shows a short message and a progress bar.
66Optionally, it can display an ABORT button
67<p>
68This dialog indicates the progress of some event that takes a while to accomplish,
69usually, such as file copy progress, download progress, and so on. The display
70is <b>completely</b> under control of the program; you must update the dialog from
71within the program creating it.
72<p>
73When the dialog closes, you must check to see if the user aborted the process or
74not, and act accordingly -- that is, if the PD_CAN_ABORT style flag is set.
75If not then you may progress blissfully onward.
76</body></html>
77"""
78
79if __name__ == '__main__':
80 import sys,os
81 import run
82 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])