This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mathdeptv2/工具v2/批量收录题目.py

52 lines
1.7 KiB
Python

from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
from Ui_批量收录题目 import Ui_Form
from database_tools import *
class MyWindow(QWidget,Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.bind()
def bind(self):
self.suffix_checked = True
self.checkBox_suffix.toggled.connect(self.togglesuffix)
self.pushButton_exec.clicked.connect(self.exec)
def togglesuffix(self):
self.suffix_checked = self.checkBox_suffix.isChecked()
if self.suffix_checked:
self.lineEdit_suffix.setEnabled(True)
else:
self.lineEdit_suffix.setDisabled(True)
def exec(self):
starting_id = self.lineEdit_startingid.text().strip().zfill(6)
raworigin = self.lineEdit_origin.text().strip()
filename = "临时文件/新题比对.tex" #题目的来源.tex文件
editor = self.lineEdit_editor.text().strip()
if self.checkBox_suffix.isChecked():
Indexed = True
else:
Indexed = False
idlistpath = "文本文件/新题收录列表.txt"
problems = GenerateProblemListFromString2024(ReadTextFile(filename))
pro_dict = load_dict("../题库0.3/Problems.json")
idlist = AddProblemstoDict2024(NextSpareID(starting_id,pro_dict),raworigin,problems,editor,Indexed,pro_dict)
save_dict(SortDict(pro_dict),r"../题库0.3/Problems.json")
AppendTextFile(f"{GetDate()}-{GetTime()}\n{generate_exp(idlist)}",idlistpath)
os.system(f"code {idlistpath}")
if __name__ == '__main__':
app = QApplication([])
windows = MyWindow()
windows.show()
app.exec()