]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | from wxPython.wx import * | |
3 | ||
4 | import 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 | ||
19 | ID_Start = wxNewId() | |
20 | ID_Stop = wxNewId() | |
21 | ID_Timer = wxNewId() | |
22 | ID_Timer2 = wxNewId() | |
23 | ||
24 | class 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 | ||
66 | def runTest(frame, nb, log): | |
67 | win = TestTimerWin(nb, log) | |
68 | return win | |
69 | ||
70 | #--------------------------------------------------------------------------- | |
71 | ||
72 | ||
73 | ||
74 | ||
75 | ||
76 | ||
77 | ||
78 | ||
79 | ||
80 | ||
81 | ||
82 | overview = """\ | |
83 | The wxTimer class allows you to execute code at specified intervals. | |
84 | ||
85 | """ | |
86 | ||
87 | ||
88 | ||
89 | ||
90 | ||
91 | ||
92 | ||
93 | ||
94 |