|
|
|
@ -6,7 +6,7 @@
|
|
|
|
|
"""
|
|
|
|
|
import pickle
|
|
|
|
|
import random
|
|
|
|
|
|
|
|
|
|
import qdarkstyle
|
|
|
|
|
from PySide6.QtCore import QTimer
|
|
|
|
|
from PySide6.QtWidgets import *
|
|
|
|
|
from PySide6.QtGui import QIcon
|
|
|
|
@ -38,6 +38,8 @@ class Form(Form1):
|
|
|
|
|
super().__init__()
|
|
|
|
|
self.setupUi(self)
|
|
|
|
|
self.total_seconds = 0
|
|
|
|
|
self.change_flag = 0
|
|
|
|
|
self.B_save.setDisabled(True)
|
|
|
|
|
# self.test()
|
|
|
|
|
self.konami_code = [65, 66, 65, 66]
|
|
|
|
|
# self.lll =[]
|
|
|
|
@ -135,6 +137,20 @@ class Form(Form1):
|
|
|
|
|
self.B8_7.clicked.connect(self.put_num)
|
|
|
|
|
self.B8_8.clicked.connect(self.put_num)
|
|
|
|
|
|
|
|
|
|
def closeEvent(self, event):
|
|
|
|
|
if self.change_flag == 1:
|
|
|
|
|
message_box = QMessageBox()
|
|
|
|
|
message_box.setWindowTitle("提示")
|
|
|
|
|
message_box.setText("是否要保存进度?")
|
|
|
|
|
message_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
|
|
|
|
|
message_box.setDefaultButton(QMessageBox.No)
|
|
|
|
|
yes_button = message_box.button(QMessageBox.Yes)
|
|
|
|
|
yes_button.clicked.connect(self.B_save_fun)
|
|
|
|
|
|
|
|
|
|
no_button = message_box.button(QMessageBox.No)
|
|
|
|
|
|
|
|
|
|
message_box.exec()
|
|
|
|
|
|
|
|
|
|
# 重写窗口按键事件
|
|
|
|
|
def keyPressEvent(self, event):
|
|
|
|
|
global sudo
|
|
|
|
@ -168,22 +184,27 @@ class Form(Form1):
|
|
|
|
|
|
|
|
|
|
def B_save_fun(self):
|
|
|
|
|
global sudo,cnt,del_cnt
|
|
|
|
|
try:
|
|
|
|
|
# 保存已填处,第一位用于记录cnt,第二位记录delcnt,第三位记录time
|
|
|
|
|
answer_list = [cnt,del_cnt, self.total_seconds]
|
|
|
|
|
|
|
|
|
|
# 保存已填处,第一位用于记录cnt,第二位记录delcnt,第三位记录time
|
|
|
|
|
answer_list = [cnt,del_cnt, self.total_seconds]
|
|
|
|
|
with open('as.pickle', 'wb') as f:
|
|
|
|
|
# 使用pickle的dump函数将对象写入文件
|
|
|
|
|
pickle.dump(answer_list, f)
|
|
|
|
|
|
|
|
|
|
with open('as.pickle', 'wb') as f:
|
|
|
|
|
# 使用pickle的dump函数将对象写入文件
|
|
|
|
|
pickle.dump(answer_list, f)
|
|
|
|
|
with open('sudo.pickle', 'wb') as f:
|
|
|
|
|
# 使用pickle的dump函数将对象写入文件
|
|
|
|
|
pickle.dump(sudo, f)
|
|
|
|
|
|
|
|
|
|
with open('sudo.pickle', 'wb') as f:
|
|
|
|
|
# 使用pickle的dump函数将对象写入文件
|
|
|
|
|
pickle.dump(sudo, f)
|
|
|
|
|
QMessageBox.information(self, '提示', '保存成功')
|
|
|
|
|
except Exception as e:
|
|
|
|
|
QMessageBox.information(self, '提示', f'保存发生错误:{e}')
|
|
|
|
|
|
|
|
|
|
print(f"已保存{answer_list[0]}个有效答案")
|
|
|
|
|
|
|
|
|
|
def B_read_fun(self):
|
|
|
|
|
global sudo, cnt, subject_with_answer,del_cnt
|
|
|
|
|
self.change_flag = 1
|
|
|
|
|
self.B_save.setDisabled(False)
|
|
|
|
|
answer_list = None
|
|
|
|
|
with open('as.pickle', 'rb') as f:
|
|
|
|
|
# 使用pickle的load函数从文件中读取对象
|
|
|
|
@ -210,7 +231,7 @@ class Form(Form1):
|
|
|
|
|
|
|
|
|
|
def B_back(self):
|
|
|
|
|
global stack, cnt, subject_with_answer
|
|
|
|
|
|
|
|
|
|
self.change_flag = 1
|
|
|
|
|
try:
|
|
|
|
|
top = stack.pop()
|
|
|
|
|
info = top.split(",", 1)
|
|
|
|
@ -311,6 +332,8 @@ class Form(Form1):
|
|
|
|
|
global cnt, del_cnt, stack, sudo, subject_with_answer
|
|
|
|
|
|
|
|
|
|
# 清零
|
|
|
|
|
self.change_flag = 1
|
|
|
|
|
self.B_save.setDisabled(False)
|
|
|
|
|
cnt = 0
|
|
|
|
|
stack.clear()
|
|
|
|
|
self.total_seconds = 0
|
|
|
|
@ -359,6 +382,7 @@ if __name__ == '__main__':
|
|
|
|
|
sudo = None
|
|
|
|
|
app = QApplication()
|
|
|
|
|
win = Form()
|
|
|
|
|
# app.setStyleSheet(qdarkstyle.load_stylesheet())
|
|
|
|
|
win.setWindowIcon(QIcon('src/sudo32.png'))
|
|
|
|
|
win.show()
|
|
|
|
|
app.exec()
|
|
|
|
|