-
Notifications
You must be signed in to change notification settings - Fork 0
/
suijiSet_pane.py
77 lines (68 loc) · 2.73 KB
/
suijiSet_pane.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
# encoding: utf-8
# @author: w4dll
# @file: suijiSet_pane.py
# @time: 2020/5/24 0:40
from PyQt5.Qt import*
from resource.suiji_set import Ui_Form
from mytool import writejson, readjson
class suijiSetPane(QWidget, Ui_Form):
def __init__(self, parent = None, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
self.setupUi(self)
data = readjson("data/suiji_set.json")
if len(data) == 0:
self.lineEdit_num_1.setText("0")
self.lineEdit_num_2.setText("0")
self.lineEdit_num_3.setText("0")
self.lineEdit_num_4.setText("0")
self.lineEdit_num_5.setText("0")
self.lineEdit_val_1.setText("1")
self.lineEdit_val_2.setText("1")
self.lineEdit_val_3.setText("1")
self.lineEdit_val_4.setText("1")
self.lineEdit_val_5.setText("1")
else:
self.lineEdit_num_1.setText(str(data[0][0]))
self.lineEdit_num_2.setText(str(data[0][1]))
self.lineEdit_num_3.setText(str(data[0][2]))
self.lineEdit_num_4.setText(str(data[0][3]))
self.lineEdit_num_5.setText(str(data[0][4]))
self.lineEdit_val_1.setText(str(data[1][0]))
self.lineEdit_val_2.setText(str(data[1][1]))
self.lineEdit_val_3.setText(str(data[1][2]))
self.lineEdit_val_4.setText(str(data[1][3]))
self.lineEdit_val_5.setText(str(data[1][4]))
def on_clicked(self):
list_num = [self.lineEdit_num_1, self.lineEdit_num_2, self.lineEdit_num_3, self.lineEdit_num_4, self.lineEdit_num_5]
list_val = [self.lineEdit_val_1, self.lineEdit_val_2, self.lineEdit_val_3, self.lineEdit_val_4, self.lineEdit_val_5]
l1, l2 = [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]
for i in range(5):
try:
l1[i] = int(list_num[i].text())
except:
list_num[i].clear()
list_num[i].setPlaceholderText("Error")
list_num[i].setFocus()
return
try:
l2[i] = int(list_val[i].text())
except:
list_val[i].clear()
list_val[i].setPlaceholderText("Error")
list_val[i].setFocus()
return
writejson("data/suiji_set.json", [l1, l2])
QMessageBox.about(self, "提示", "随机设置成功!")
self.close()
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
win = suijiSetPane()
win.show()
sys.exit(app.exec_())
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
win = suijiSetPane()
win.show()
sys.exit(app.exec_())