-
Notifications
You must be signed in to change notification settings - Fork 0
/
M_Roll.py
105 lines (85 loc) · 2.7 KB
/
M_Roll.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
##############################
# import
##############################
import wx
import random
import time
import threading
import GUI_Roll
##############################
# GUI的函数桥接
##############################
class CalcFrame(GUI_Roll.Main):
def __init__(self, parent):
# 定义主函数
GUI_Roll.Main.__init__(self, parent)
self.SetDoubleBuffered(True) # 声明:启用双缓冲
self.notebook.SetSelection(0)
if self.Using_TimeSeed.IsChecked() == False:
random.seed(self.SP_Seed.GetValue())
else:
##print(time.time())
random.seed(time.time())
def A_RUN(self, event):
self.A_DATA.Clear()
if self.A_AutoLineFeed.IsChecked() == True:
for i in range(0, self.A_Amount.GetValue()):
self.A_DATA.AppendText(str(random.randint(self.A_MIN.GetValue(), self.A_MAX.GetValue())) + '\n')
else:
for i in range(0, self.A_Amount.GetValue()):
self.A_DATA.AppendText(str(random.randint(self.A_MIN.GetValue(), self.A_MAX.GetValue())) + self.A_Separator.GetString(self.A_Separator.GetSelection()))
def A_AutoLineFeedOnCheckBox(self, event):
if self.A_AutoLineFeed.IsChecked() == True:
self.A_T_Separator.Enable(False)
self.A_Separator.Enable(False)
else:
self.A_T_Separator.Enable(True)
self.A_Separator.Enable(True)
#--------------------------------------------------------------------------
def B_RUN(self, event):
thr = threading.Thread(target=self.B_RUN_threading)
thr.start()
def B_RUN_threading(self,*event):
self.B_B_RUN.Enable(False)
##Resize(self)
for i in range(0,100):
if i < 80:
##wx.MilliSleep(10)
time.sleep(0.01)
self.B_DATA.SetLabel(str(random.randint(self.B_MIN.GetValue(), self.B_MAX.GetValue())))
elif i < 95:
##wx.MilliSleep(50)
time.sleep(0.05)
self.B_DATA.SetLabel(str(random.randint(self.B_MIN.GetValue(), self.B_MAX.GetValue())))
else:
##wx.MilliSleep(100)
time.sleep(0.1)
self.B_DATA.SetLabel(str(random.randint(self.B_MIN.GetValue(), self.B_MAX.GetValue())))
self.B_B_RUN.Enable(True)
#--------------------------------------------------------------------------
def SP_SeedOnSpinCtrl(self, event):
random.seed(self.SP_Seed.GetValue())
def Using_TimeSeedOnCheckBox(self, event):
if self.Using_TimeSeed.IsChecked() == True:
self.T_SP_Seed.Enable(False)
self.SP_Seed.Enable(False)
random.seed(time.time())
else:
self.T_SP_Seed.Enable(True)
self.SP_Seed.Enable(True)
def Close(self, event):
self.Destroy()
##############################
# 主函数
##############################
def main():
global app
app = wx.App(False)
frame = CalcFrame(None)
frame.Show(True)
app.MainLoop()
def Resize(self):
self.SetSize(500,401)
self.SetSize(500,400)
if __name__ == "__main__":
main()