]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxTimer.py
suppress an assert when a combobox receives WM_KILLFOCUS while it is being destroyed
[wxWidgets.git] / wxPython / demo / wxTimer.py
CommitLineData
cf694132
RD
1
2from wxPython.wx import *
3
4import time
5
6#---------------------------------------------------------------------------
7
e6157a69
RD
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')
cf694132
RD
16
17#---------------------------------------------------------------------------
18
b96c7a38
RD
19ID_Start = wxNewId()
20ID_Stop = wxNewId()
21ID_Timer = wxNewId()
22ID_Timer2 = wxNewId()
cf694132
RD
23
24class TestTimerWin(wxPanel):
25 def __init__(self, parent, log):
cf694132 26 wxPanel.__init__(self, parent, -1)
e6157a69 27 self.log = log
cf694132
RD
28
29 wxStaticText(self, -1, "This is a timer example",
30 wxPoint(15, 30))
31
e6157a69
RD
32 wxButton(self, ID_Start, ' Start ', wxPoint(15, 75), wxDefaultSize)
33 wxButton(self, ID_Stop, ' Stop ', wxPoint(115, 75), wxDefaultSize)
34
35 self.timer = wxTimer(self, # object to send the event to
36 ID_Timer) # event id to use
37
b96c7a38
RD
38 self.timer2 = wxTimer(self, # object to send the event to
39 ID_Timer2) # event id to use
40
e6157a69
RD
41 EVT_BUTTON(self, ID_Start, self.OnStart)
42 EVT_BUTTON(self, ID_Stop, self.OnStop)
43 EVT_TIMER(self, ID_Timer, self.OnTimer)
b96c7a38 44 EVT_TIMER(self, ID_Timer2, self.OnTimer2)
cf694132
RD
45
46 def OnStart(self, event):
e6157a69 47 self.timer.Start(1000)
b96c7a38 48 self.timer2.Start(1500)
cf694132
RD
49
50 def OnStop(self, event):
e6157a69 51 self.timer.Stop()
b96c7a38 52 self.timer2.Stop()
e6157a69
RD
53
54 def OnTimer(self, event):
55 wxBell()
56 if self.log:
57 self.log.WriteText('beep!\n')
cf694132 58
b96c7a38
RD
59 def OnTimer2(self, event):
60 wxBell()
61 if self.log:
62 self.log.WriteText('beep 2!\n')
63
cf694132
RD
64#---------------------------------------------------------------------------
65
66def runTest(frame, nb, log):
67 win = TestTimerWin(nb, log)
68 return win
69
70#---------------------------------------------------------------------------
71
72
73
74
75
76
77
78
79
80
81
82overview = """\
68d92db3 83The wxTimer class allows you to execute code at specified intervals.
cf694132 84
cf694132 85"""
68d92db3
RD
86
87
88
89
90
91
92
93
94