]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxTimer.py
Unicode compilation fixes
[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
e6157a69
RD
19ID_Start = wxNewId()
20ID_Stop = wxNewId()
21ID_Timer = wxNewId()
cf694132
RD
22
23class TestTimerWin(wxPanel):
24 def __init__(self, parent, log):
cf694132 25 wxPanel.__init__(self, parent, -1)
e6157a69 26 self.log = log
cf694132
RD
27
28 wxStaticText(self, -1, "This is a timer example",
29 wxPoint(15, 30))
30
e6157a69
RD
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
cf694132
RD
41
42 def OnStart(self, event):
e6157a69 43 self.timer.Start(1000)
cf694132
RD
44
45 def OnStop(self, event):
e6157a69
RD
46 self.timer.Stop()
47
48 def OnTimer(self, event):
49 wxBell()
50 if self.log:
51 self.log.WriteText('beep!\n')
cf694132
RD
52
53#---------------------------------------------------------------------------
54
55def 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
71overview = """\
68d92db3 72The wxTimer class allows you to execute code at specified intervals.
cf694132 73
cf694132 74"""
68d92db3
RD
75
76
77
78
79
80
81
82
83