-
Notifications
You must be signed in to change notification settings - Fork 0
/
Class_Registration_Master.py
337 lines (247 loc) · 12 KB
/
Class_Registration_Master.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
'''
======================================================================================
< Class_Registration_Master_v1.0 >
'수강신청 마스터'를 사용해 나머지 99%의 사람들에게 당신과의 격차를 확실히 느끼게 해주십시오.
* Made by Yoonmen *
- 23.1.29 (SUN) 02:22 -
======================================================================================
'''
import sys
from PySide2.QtWidgets import QApplication, QTreeWidgetItem
from PySide2.QtCore import QThread, QObject, QEvent
from PySide2.QtGui import QIcon
import time
from CRM_mainUI import MainUI
from CRM_keyFn import KeyFn
class Main(QObject) :
def __init__(self) :
super().__init__()
global mainUI
mainUI = MainUI()
global thread_keyFn
thread_keyFn = QThread()
thread_keyFn.start()
global keyFn
keyFn = KeyFn()
keyFn.moveToThread(thread_keyFn)
global thread_basicFn
thread_basicFn = QThread()
thread_basicFn.start()
global basicFn
basicFn = BasicFn()
basicFn.moveToThread(thread_basicFn)
global subjectData
subjectData = {}
global majorSubjectCnt
majorSubjectCnt = 0
global power
power = False
global subjectIsSaved
subjectIsSaved = True
mainUI.show()
self.signal()
sys.exit(app.exec_())
def signal(self) :
# << mainUI (1/1) >> --------------------
## prepare_part
mainUI.prepare_rb.clicked.connect(self.finale_inProgress)
mainUI.subjectCode_le.returnPressed.connect(basicFn.addSubject)
mainUI.addSubject_bt.clicked.connect(basicFn.addSubject)
mainUI.subjectBox_tw.viewport().installEventFilter(self)
mainUI.subjectSave_bt.clicked.connect(BasicFn.setSubjectData)
mainUI.subjectBin_bt.clicked.connect(BasicFn.delSubject)
mainUI.prepare_rb.clicked.connect(self.chkSubjectSave)
mainUI.subject_rb.clicked.connect(self.chkSubjectSave)
## finale_part
mainUI.finale_rb.clicked.connect(self.setFinale_lb)
mainUI.start_bt.clicked.connect(basicFn.classRegistration)
mainUI.cancel_bt.clicked.connect(self.powerOff)
def finale_inProgress(self) :
if power :
mainUI.body_frm.hide()
mainUI.finale_inProgress_lb.show()
mainUI.finale_inProgress_bt.show()
def chkSubjectSave(self) :
if mainUI.subject_rb.isChecked() :
if not subjectIsSaved :
mainUI.savePoint_lb.show()
def setFinale_lb(self) :
if mainUI.university_cb.currentIndex() == 0 : universityIsPrepared = False
else : universityIsPrepared = True
if (mainUI.ID_box_le.text() == "") or (mainUI.PW_box_le.text() == "") : accountIsPrepared = False
else : accountIsPrepared = True
if (int(mainUI.hour_box_le.text()) == 0) and (int(mainUI.min_box_le.text()) == 0) : timeIsPrepared = False
else : timeIsPrepared = True
if (len(subjectData) == 0) or (not subjectIsSaved) : subjectIsPrepared = False
else : subjectIsPrepared = True
if universityIsPrepared : mainUI.universityIsPrepared()
else : mainUI.universityIsNotPrepared()
if accountIsPrepared : mainUI.accountIsPrepared()
else : mainUI.accountIsNotPrepared()
if timeIsPrepared : mainUI.timeIsPrepared()
else : mainUI.timeIsNotPrepared()
if subjectIsPrepared : mainUI.subjectIsPrepared()
else : mainUI.subjectIsNotPrepared()
def powerOff(self) :
global power
power = False
def eventFilter(self, object, event) :
if object == mainUI.subjectBox_tw.viewport() :
if event.type() == QEvent.Drop :
global subjectIsSaved
subjectIsSaved = False
mainUI.savePoint_lb.show()
return False
class BasicFn(QObject) :
def setSubjectBox(self) :
tmp = []
for major, insurances in subjectData.items() :
item = QTreeWidgetItem(major)
for insurance in insurances :
subItem = QTreeWidgetItem(insurance)
item.addChild(subItem)
tmp.append(item)
mainUI.subjectBox_tw.clear()
mainUI.subjectBox_tw.insertTopLevelItems(0, tmp)
def addSubject(self) :
subjectName, subjectCode = mainUI.subjectName_le.text(), mainUI.subjectCode_le.text()
if (subjectName == "") or (subjectCode == "") :
mainUI.body_frm.hide()
mainUI.subjectError_lb.show()
mainUI.subjectError_bt.show()
else :
global subjectData
subjectData[(subjectName, subjectCode)] = []
basicFn.setSubjectBox()
global majorSubjectCnt
majorSubjectCnt += 1
mainUI.completed_txt_lb.setText(str(majorSubjectCnt))
mainUI.subjectName_le.setText(""); mainUI.subjectCode_le.setText("")
def setSubjectData(self) :
def recursiveSet(veryMajor, major) :
insuranceCnt = major.childCount()
for j in range(insuranceCnt) :
insurance = major.child(j)
subjectData[(veryMajor.text(0), veryMajor.text(1))].append((insurance.text(0), insurance.text(1)))
ininsuranceCnt = insurance.childCount()
if ininsuranceCnt > 0 :
recursiveSet(veryMajor, insurance)
global subjectData, majorSubjectCnt
subjectData = {}
majorSubjectCnt = 0
for i in range(mainUI.subjectBox_tw.topLevelItemCount()) :
major = mainUI.subjectBox_tw.topLevelItem(i)
subjectData[(major.text(0), major.text(1))] = []
majorSubjectCnt += 1
recursiveSet(major, major)
basicFn.setSubjectBox()
mainUI.completed_txt_lb.setText(str(majorSubjectCnt))
global subjectIsSaved
subjectIsSaved = True
mainUI.savePoint_lb.hide()
def delSubject(self) :
if mainUI.subjectBox_tw.currentItem() :
item = mainUI.subjectBox_tw.currentItem()
if item.parent() :
item.parent().removeChild(item)
else :
mainUI.subjectBox_tw.takeTopLevelItem(mainUI.subjectBox_tw.indexOfTopLevelItem(item))
basicFn.setSubjectData()
def timeChk(self) :
CR_H = int(mainUI.hour_box_le.text())
CR_M = int(mainUI.min_box_le.text())
crt_H = time.localtime().tm_hour
crt_M = time.localtime().tm_min
crt_S = time.localtime().tm_sec
total = (CR_H*3600 + CR_M*60) - (crt_H*3600 + crt_M*60 + crt_S)
if total < 0 : return 0
return total
def classRegistration(self) :
if mainUI.university_cb.currentIndex() == 0 : universityIsPrepared = False
else : universityIsPrepared = True
if (mainUI.ID_box_le.text() == "") or (mainUI.PW_box_le.text() == "") : accountIsPrepared = False
else : accountIsPrepared = True
if (int(mainUI.hour_box_le.text()) == 0) and (int(mainUI.min_box_le.text()) == 0) : timeIsPrepared = False
else : timeIsPrepared = True
if (len(subjectData) == 0) or (not subjectIsSaved) : subjectIsPrepared = False
else : subjectIsPrepared = True
if universityIsPrepared and accountIsPrepared and timeIsPrepared and subjectIsPrepared :
remainingTime = self.timeChk()
global power
power = True
while (remainingTime > 0) and (power) :
if (remainingTime == 300) or (remainingTime == 60) : remainingTime = self.timeChk()
remainingTime -= 1
H, M, S = remainingTime//3600, remainingTime%3600//60, remainingTime%60
mainUI.time_HM_lcd.display(f"{str(H).zfill(2)}:{str(M).zfill(2)}")
mainUI.time_S_lcd.display(f":{str(S).zfill(2)}")
time.sleep(1)
if power :
account = (mainUI.ID_box_le.text(), mainUI.PW_box_le.text())
mainUI.body_frm.hide()
mainUI.registrationScreen_gif_lb.show()
mainUI.registrationScreen_txt_lb.show()
universityNum = mainUI.university_cb.currentIndex()
if universityNum == 1 :
result = keyFn.classRegistration_KIT(account, subjectData)
elif universityNum == 2 :
result = keyFn.classRegistration_DNUE(account, subjectData)
elif universityNum == 3 :
result = keyFn.classRegistration_SKKU(account, subjectData)
mainUI.registrationScreen_gif_lb.hide()
mainUI.registrationScreen_txt_lb.hide()
if isinstance(result, dict) :
tmp = []
for major, insurances in subjectData.items() :
item = QTreeWidgetItem()
item.setText(0, major[0]); item.setText(1, major[1])
if not major in result :
item.setIcon(2, QIcon(":/img/o_mark_lb.png"))
else :
item.setIcon(2, QIcon(":/img/x_mark_lb.png"))
item.setText(3, result[major])
for insurance in insurances :
subItem = QTreeWidgetItem()
subItem.setText(0, insurance[0]); subItem.setText(1, insurance[1])
if not insurance in result :
subItem.setIcon(2, QIcon(":/img/o_mark_lb.png"))
item.addChild(subItem)
break
else :
subItem.setIcon(2, QIcon(":/img/x_mark_lb.png"))
subItem.setText(3, result[insurance])
item.addChild(subItem)
tmp.append(item)
mainUI.report_tw.insertTopLevelItems(0, tmp)
mainUI.report_tw.show()
mainUI.report_tw.expandAll()
mainUI.report_bt.show()
mainUI.report_lb.show()
else :
if result == "pageError" :
mainUI.pageError_lb.show()
mainUI.pageError_bt.show()
elif result == "accountError" :
mainUI.accountError_lb.show()
mainUI.accountError_bt.show()
elif result == "periodError" :
mainUI.periodError_lb.show()
mainUI.periodError_bt.show()
power = False
mainUI.changeSCMode()
mainUI.time_HM_lcd.display("--:--"); mainUI.time_S_lcd.display(":--")
else :
mainUI.body_frm.hide()
mainUI.finale_notPrepared_lb.show()
mainUI.finale_notPrepared_bt.show()
if universityIsPrepared : mainUI.university_O_mark_lb.show()
else : mainUI.university_X_mark_lb.show()
if accountIsPrepared : mainUI.account_O_mark_lb.show()
else : mainUI.account_X_mark_lb.show()
if timeIsPrepared : mainUI.time_O_mark_lb.show()
else : mainUI.time_X_mark_lb.show()
if subjectIsPrepared : mainUI.subject_O_mark_lb.show()
else : mainUI.subject_X_mark_lb.show()
if __name__ == "__main__" :
app = QApplication(sys.argv)
Main()