优化退出保存逻辑

master-class
MrB 11 months ago
parent 6d53be0ad2
commit 033735580a

@ -172,9 +172,6 @@ class Form(Form1):
# self.lll.append(key)
# print(self.lll)
def update_time(self):
self.total_seconds += 1
@ -186,10 +183,11 @@ class Form(Form1):
self.lcdNumber.display(time_str)
def B_save_fun(self):
global sudo,cnt,del_cnt
global sudo, cnt, del_cnt
try:
# 保存已填处,第一位用于记录cnt,第二位记录delcnt第三位记录time
answer_list = [cnt,del_cnt, self.total_seconds]
answer_list = [cnt, del_cnt, self.total_seconds]
with open('as.pickle', 'wb') as f:
# 使用pickle的dump函数将对象写入文件
@ -200,13 +198,13 @@ class Form(Form1):
pickle.dump(sudo, f)
QMessageBox.information(self, '提示', '保存成功')
self.change_flag = 0
except Exception as e:
QMessageBox.information(self, '提示', f'保存发生错误:{e}')
def B_read_fun(self):
global sudo, cnt, subject_with_answer,del_cnt
self.change_flag = 1
global sudo, cnt, subject_with_answer, del_cnt
self.change_flag = 0
self.B_save.setDisabled(False)
answer_list = None
with open('as.pickle', 'rb') as f:
@ -229,8 +227,7 @@ class Form(Form1):
self.translate(sudo.subject)
subject_with_answer = sudo.subject_with_answer
i = 1
self.translate(subject_with_answer,1)
self.translate(subject_with_answer, 1)
def B_back(self):
global stack, cnt, subject_with_answer
@ -251,7 +248,7 @@ class Form(Form1):
except Exception as e:
print(e)
def check_sudo(self,mode=0):
def check_sudo(self, mode=0):
global cnt, del_cnt, subject_with_answer
f = 1
@ -281,6 +278,7 @@ class Form(Form1):
# print("yes")
if del_cnt == cnt:
QMessageBox.information(self, '提示', '成功')
self.change_flag = 0
self.timer.stop()
else:
# print("no")
@ -300,10 +298,6 @@ class Form(Form1):
else:
self.move(self.x() - 7, self.y())
def put_num(self):
global cnt, del_cnt, subject_with_answer, stack
@ -350,6 +344,7 @@ class Form(Form1):
self.check_sudo()
else:
self.check_sudo(1)
self.change_flag = 1
def B_S_fun(self):
global cnt, del_cnt, stack, sudo, subject_with_answer

Loading…
Cancel
Save