优化退出保存逻辑

master-class
MrB 1 year ago
parent 6d53be0ad2
commit 033735580a

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

Loading…
Cancel
Save