-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
67 lines (58 loc) · 2.64 KB
/
main.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
from mainui import Ui_MainWindow
from func import *
from PyQt6.QtWidgets import *
from PyQt6.QtCore import *
from PyQt6.QtGui import *
import sys
import json
class WindowGui(QMainWindow,Ui_MainWindow):
def __init__(self):
super(WindowGui,self).__init__()
self.setWindowIcon(QIcon('logo.ico'))
self.setupUi(self)
self.qsettings = QSettings("config.ini")
#涂鸦
self.tuya_check.setChecked(self.str2bool(self.qsettings.value('tuyaCheckState')))
self.tuya_choice.setCurrentIndex(self.qsettings.value('tuyaChoice',type=int))
self.tuya_dif.setCurrentIndex(self.qsettings.value('tuyaDif',type=int))
self.tuya_times.setText(self.qsettings.value('tuyaTimes'))
#钓鱼
# print((self.qsettings.value('fishingCheckState')))
self.fishing_check.setChecked(self.str2bool(self.qsettings.value('fishingCheckState')))
self.fishing_point.setCurrentIndex(self.qsettings.value('fishingPoint',type=int))
self.fishing_times.setText(self.qsettings.value('fishingTimes'))
self.data = None
self.load_data.clicked.connect(self.loadData)
self.save.clicked.connect(self.saveSettings)
self.confirm.clicked.connect(self.taskConfirm)
def str2bool(self, str):
if str == 'true':
return True
else:
return False
def saveSettings(self):
self.qsettings.setValue('tuyaCheckState', self.tuya_check.isChecked())
self.qsettings.setValue('fishingCheckState', self.tuya_check.isChecked())
self.qsettings.setValue("tuyaChoice",self.tuya_choice.currentIndex())
self.qsettings.setValue("tuyaDif",self.tuya_dif.currentIndex())
self.qsettings.setValue("tuyaTimes",self.tuya_times.text())
self.qsettings.setValue("fishingPoint",self.fishing_point.currentIndex())
self.qsettings.setValue("fishingTimes",self.fishing_times.text())
def taskConfirm(self):
if self.fishing_check.isChecked():
diaoyu = Fishing(int(self.fishing_times.text()),self.fishing_point.currentIndex(), self.data)
diaoyu.fishing()
if self.tuya_check.isChecked():
tuya = Tuya(self.tuya_choice.currentIndex(), self.tuya_dif.currentIndex(), int(self.tuya_times.text()), self.data)
tuya.stuya()
def loadData(self):
try:
with open('data.json', 'r', encoding='utf-8') as f:
self.data = json.load(f)
except:
raise FileExistsError('配置文件不存在')
if __name__ == '__main__':
app = QApplication(sys.argv)
window = WindowGui()
window.show()
sys.exit(app.exec())