-
Notifications
You must be signed in to change notification settings - Fork 0
/
M_Timer.py
111 lines (93 loc) · 2.16 KB
/
M_Timer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
##############################
# import
##############################
import wx
import GUI_Timer
##############################
# GUI的函数桥接
##############################
class CalcFrame(GUI_Timer.Main):
def __init__(self, parent):
# 定义主函数
GUI_Timer.Main.__init__(self, parent)
self.Text_min.Show(False)
self.Text_sec.Show(False)
self.mao.Show(False)
self.Stop.Show(False)
self.Pause.Show(False)
def run(self, event):
global min, sec
self.timer.Start(1000)
self.RUN.Show(False)
self.Text_min.Show(True)
self.Text_sec.Show(True)
self.mao.Show(True)
self.Stop.Show(True)
self.Pause.Show(True)
self.MIN.Show(False)
self.SEC.Show(False)
self.text1.Show(False)
self.text2.Show(False)
min = self.MIN.GetValue()
sec = self.SEC.GetValue()
self.Text_sec.SetLabel(str(sec))
self.Text_min.SetLabel(str(min))
self.SetSize(401, 300)
self.SetSize(400, 300)
def Tick(self, event):
global min, sec
if sec != 0:
sec = sec - 1
self.Text_sec.SetLabel(str(sec))
elif min != 0:
min = min - 1
self.Text_min.SetLabel(str(min))
sec = 59
self.Text_sec.SetLabel(str(sec))
else:
self.timer.Stop()
self.RUN.Show(True)
self.Text_min.Show(False)
self.Text_sec.Show(False)
self.mao.Show(False)
self.MIN.Show(True)
self.SEC.Show(True)
self.text1.Show(True)
self.text2.Show(True)
self.Stop.Show(False)
self.Pause.Show(False)
def stop(self, event):
global min, sec
self.timer.Stop()
self.RUN.Show(True)
self.Text_min.Show(False)
self.Text_sec.Show(False)
self.mao.Show(False)
self.MIN.Show(True)
self.SEC.Show(True)
self.text1.Show(True)
self.text2.Show(True)
self.Stop.Show(False)
self.Pause.Show(False)
##min = 0
##sec = 30
def pause(self, event):
if self.Pause.GetLabel() == '暂停':
self.timer.Stop()
self.Pause.SetLabel('恢复')
else:
self.timer.Start(1000)
self.Pause.SetLabel('暂停')
def Close(self, event):
self.Destroy()
##############################
# 主函数
##############################
def main():
global app
app = wx.App(False)
frame = CalcFrame(None)
frame.Show(True)
app.MainLoop()
if __name__ == "__main__":
main()