]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxTimer.py
1. don't emulate OFN_OVERWRITEPROMPT, use the real thing
[wxWidgets.git] / wxPython / demo / wxTimer.py
1
2 from wxPython.wx import *
3
4 import time
5
6 #---------------------------------------------------------------------------
7
8 ## class TestTimer(wxTimer):
9 ## def __init__(self, log = None):
10 ## wxTimer.__init__(self)
11 ## self.log = log
12 ## def Notify(self):
13 ## wxBell()
14 ## if self.log:
15 ## self.log.WriteText('beep!\n')
16
17 #---------------------------------------------------------------------------
18
19 ID_Start = wxNewId()
20 ID_Stop = wxNewId()
21 ID_Timer = wxNewId()
22
23 class TestTimerWin(wxPanel):
24 def __init__(self, parent, log):
25 wxPanel.__init__(self, parent, -1)
26 self.log = log
27
28 wxStaticText(self, -1, "This is a timer example",
29 wxPoint(15, 30))
30
31 wxButton(self, ID_Start, ' Start ', wxPoint(15, 75), wxDefaultSize)
32 wxButton(self, ID_Stop, ' Stop ', wxPoint(115, 75), wxDefaultSize)
33
34 self.timer = wxTimer(self, # object to send the event to
35 ID_Timer) # event id to use
36
37 EVT_BUTTON(self, ID_Start, self.OnStart)
38 EVT_BUTTON(self, ID_Stop, self.OnStop)
39 EVT_TIMER(self, ID_Timer, self.OnTimer)
40
41
42 def OnStart(self, event):
43 self.timer.Start(1000)
44
45 def OnStop(self, event):
46 self.timer.Stop()
47
48 def OnTimer(self, event):
49 wxBell()
50 if self.log:
51 self.log.WriteText('beep!\n')
52
53 #---------------------------------------------------------------------------
54
55 def runTest(frame, nb, log):
56 win = TestTimerWin(nb, log)
57 return win
58
59 #---------------------------------------------------------------------------
60
61
62
63
64
65
66
67
68
69
70
71 overview = """\
72 The wxTimer class allows you to execute code at specified intervals.
73
74 """
75
76
77
78
79
80
81
82
83