]>
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 #---------------------------------------------------------------------------
23 class TestTimerWin(wxPanel
):
24 def __init__(self
, parent
, log
):
25 wxPanel
.__init
__(self
, parent
, -1)
28 wxStaticText(self
, -1, "This is a timer example",
31 wxButton(self
, ID_Start
, ' Start ', wxPoint(15, 75), wxDefaultSize
)
32 wxButton(self
, ID_Stop
, ' Stop ', wxPoint(115, 75), wxDefaultSize
)
34 self
.timer
= wxTimer(self
, # object to send the event to
35 ID_Timer
) # event id to use
37 EVT_BUTTON(self
, ID_Start
, self
.OnStart
)
38 EVT_BUTTON(self
, ID_Stop
, self
.OnStop
)
39 EVT_TIMER(self
, ID_Timer
, self
.OnTimer
)
42 def OnStart(self
, event
):
43 self
.timer
.Start(1000)
45 def OnStop(self
, event
):
48 def OnTimer(self
, event
):
51 self
.log
.WriteText('beep!\n')
53 #---------------------------------------------------------------------------
55 def runTest(frame
, nb
, log
):
56 win
= TestTimerWin(nb
, log
)
59 #---------------------------------------------------------------------------
72 The wxTimer class allows you to execute code at specified intervals.