]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/wxTimer.py
fix text scrolling in GTK2 (patch 703988)
[wxWidgets.git] / wxPython / demo / wxTimer.py
... / ...
CommitLineData
1
2from wxPython.wx import *
3
4import time
5
6#---------------------------------------------------------------------------
7
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')
16
17#---------------------------------------------------------------------------
18
19ID_Start = wxNewId()
20ID_Stop = wxNewId()
21ID_Timer = wxNewId()
22ID_Timer2 = wxNewId()
23
24class TestTimerWin(wxPanel):
25 def __init__(self, parent, log):
26 wxPanel.__init__(self, parent, -1)
27 self.log = log
28
29 wxStaticText(self, -1, "This is a timer example",
30 wxPoint(15, 30))
31
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
38 self.timer2 = wxTimer(self, # object to send the event to
39 ID_Timer2) # event id to use
40
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)
45
46 def OnStart(self, event):
47 self.timer.Start(1000)
48 self.timer2.Start(1500)
49
50 def OnStop(self, event):
51 self.timer.Stop()
52 self.timer2.Stop()
53
54 def OnTimer(self, event):
55 wxBell()
56 if self.log:
57 self.log.WriteText('beep!\n')
58
59 def OnTimer2(self, event):
60 wxBell()
61 if self.log:
62 self.log.WriteText('beep 2!\n')
63
64#---------------------------------------------------------------------------
65
66def runTest(frame, nb, log):
67 win = TestTimerWin(nb, log)
68 return win
69
70#---------------------------------------------------------------------------
71
72
73
74overview = """\
75The wxTimer class allows you to execute code at specified intervals.
76
77"""
78
79
80
81
82if __name__ == '__main__':
83 import sys,os
84 import run
85 run.main(['', os.path.basename(sys.argv[0])])