1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
from wxPython.wx import *
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2001-10-30 18:15:13 +00:00
|
|
|
## class TestTimer(wxTimer):
|
|
|
|
## def __init__(self, log = None):
|
|
|
|
## wxTimer.__init__(self)
|
|
|
|
## self.log = log
|
|
|
|
## def Notify(self):
|
|
|
|
## wxBell()
|
|
|
|
## if self.log:
|
|
|
|
## self.log.WriteText('beep!\n')
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2002-03-26 21:55:33 +00:00
|
|
|
ID_Start = wxNewId()
|
|
|
|
ID_Stop = wxNewId()
|
|
|
|
ID_Timer = wxNewId()
|
|
|
|
ID_Timer2 = wxNewId()
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
class TestTimerWin(wxPanel):
|
|
|
|
def __init__(self, parent, log):
|
|
|
|
wxPanel.__init__(self, parent, -1)
|
2001-10-30 18:15:13 +00:00
|
|
|
self.log = log
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
wxStaticText(self, -1, "This is a timer example",
|
|
|
|
wxPoint(15, 30))
|
|
|
|
|
2001-10-30 18:15:13 +00:00
|
|
|
wxButton(self, ID_Start, ' Start ', wxPoint(15, 75), wxDefaultSize)
|
|
|
|
wxButton(self, ID_Stop, ' Stop ', wxPoint(115, 75), wxDefaultSize)
|
|
|
|
|
|
|
|
self.timer = wxTimer(self, # object to send the event to
|
|
|
|
ID_Timer) # event id to use
|
|
|
|
|
2002-03-26 21:55:33 +00:00
|
|
|
self.timer2 = wxTimer(self, # object to send the event to
|
|
|
|
ID_Timer2) # event id to use
|
|
|
|
|
2001-10-30 18:15:13 +00:00
|
|
|
EVT_BUTTON(self, ID_Start, self.OnStart)
|
|
|
|
EVT_BUTTON(self, ID_Stop, self.OnStop)
|
|
|
|
EVT_TIMER(self, ID_Timer, self.OnTimer)
|
2002-03-26 21:55:33 +00:00
|
|
|
EVT_TIMER(self, ID_Timer2, self.OnTimer2)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
def OnStart(self, event):
|
2001-10-30 18:15:13 +00:00
|
|
|
self.timer.Start(1000)
|
2002-03-26 21:55:33 +00:00
|
|
|
self.timer2.Start(1500)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
def OnStop(self, event):
|
2001-10-30 18:15:13 +00:00
|
|
|
self.timer.Stop()
|
2002-03-26 21:55:33 +00:00
|
|
|
self.timer2.Stop()
|
2001-10-30 18:15:13 +00:00
|
|
|
|
|
|
|
def OnTimer(self, event):
|
|
|
|
wxBell()
|
|
|
|
if self.log:
|
|
|
|
self.log.WriteText('beep!\n')
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2002-03-26 21:55:33 +00:00
|
|
|
def OnTimer2(self, event):
|
|
|
|
wxBell()
|
|
|
|
if self.log:
|
|
|
|
self.log.WriteText('beep 2!\n')
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestTimerWin(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
overview = """\
|
2001-10-30 18:16:01 +00:00
|
|
|
The wxTimer class allows you to execute code at specified intervals.
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
"""
|
2001-10-30 18:16:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|