]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxTimer.py
2 from wxPython
.wx
import *
6 #---------------------------------------------------------------------------
8 ## class TestTimer(wxTimer):
9 ## def __init__(self, log = None):
10 ## wxTimer.__init__(self)
15 ## self.log.WriteText('beep!\n')
17 #---------------------------------------------------------------------------
24 class TestTimerWin(wxPanel
):
25 def __init__(self
, parent
, log
):
26 wxPanel
.__init
__(self
, parent
, -1)
29 wxStaticText(self
, -1, "This is a timer example",
32 wxButton(self
, ID_Start
, ' Start ', wxPoint(15, 75), wxDefaultSize
)
33 wxButton(self
, ID_Stop
, ' Stop ', wxPoint(115, 75), wxDefaultSize
)
35 self
.timer
= wxTimer(self
, # object to send the event to
36 ID_Timer
) # event id to use
38 self
.timer2
= wxTimer(self
, # object to send the event to
39 ID_Timer2
) # event id to use
41 EVT_BUTTON(self
, ID_Start
, self
.OnStart
)
42 EVT_BUTTON(self
, ID_Stop
, self
.OnStop
)
43 EVT_TIMER(self
, ID_Timer
, self
.OnTimer
)
44 EVT_TIMER(self
, ID_Timer2
, self
.OnTimer2
)
46 def OnStart(self
, event
):
47 self
.timer
.Start(1000)
48 self
.timer2
.Start(1500)
50 def OnStop(self
, event
):
54 def OnTimer(self
, event
):
57 self
.log
.WriteText('beep!\n')
59 def OnTimer2(self
, event
):
62 self
.log
.WriteText('beep 2!\n')
64 #---------------------------------------------------------------------------
66 def runTest(frame
, nb
, log
):
67 win
= TestTimerWin(nb
, log
)
70 #---------------------------------------------------------------------------
83 The wxTimer class allows you to execute code at specified intervals.