diff --git a/工具v2/Qt面板.py b/工具v2/Qt面板.py index 3c574ccb..211c71c3 100644 --- a/工具v2/Qt面板.py +++ b/工具v2/Qt面板.py @@ -27,7 +27,7 @@ class MyWindow(QMainWindow,Ui_MainWindow): def bind(self): self.action_kxth.triggered.connect(lambda: run_command("寻找空闲题号",[])) self.action_xtbd.triggered.connect(lambda: run_command("新题比对",[])) - self.action_plsl.triggered.connect(lambda: run_command("批量收录题目",["批量收录题目.py"])) + self.action_plsl.triggered.connect(lambda: run_command("批量收录题目",[])) self.action_tjgl.triggered.connect(lambda: run_command("添加关联题目",["添加关联题目.py"])) self.action_tjzd.triggered.connect(lambda: run_command("修改metadata",["文本文件/metadata.txt"])) self.action_LaTeXedit.triggered.connect(lambda: run_command("LaTeX编辑题目答案及提示",["latex编辑题目答案及提示.py"])) diff --git a/工具v2/Ui_批量收录题目.py b/工具v2/Ui_批量收录题目.py new file mode 100644 index 00000000..3c3d4fba --- /dev/null +++ b/工具v2/Ui_批量收录题目.py @@ -0,0 +1,131 @@ +# -*- coding: utf-8 -*- + +################################################################################ +## Form generated from reading UI file '批量收录题目.ui' +## +## Created by: Qt User Interface Compiler version 6.6.2 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, + QMetaObject, QObject, QPoint, QRect, + QSize, QTime, QUrl, Qt) +from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, + QFont, QFontDatabase, QGradient, QIcon, + QImage, QKeySequence, QLinearGradient, QPainter, + QPalette, QPixmap, QRadialGradient, QTransform) +from PySide6.QtWidgets import (QApplication, QCheckBox, QHBoxLayout, QLabel, + QLineEdit, QPushButton, QSizePolicy, QSplitter, + QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(342, 109) + self.pushButton_exec = QPushButton(Form) + self.pushButton_exec.setObjectName(u"pushButton_exec") + self.pushButton_exec.setGeometry(QRect(260, 10, 71, 91)) + font = QFont() + font.setBold(True) + self.pushButton_exec.setFont(font) + self.splitter = QSplitter(Form) + self.splitter.setObjectName(u"splitter") + self.splitter.setGeometry(QRect(10, 10, 241, 88)) + self.splitter.setOrientation(Qt.Vertical) + self.widget = QWidget(self.splitter) + self.widget.setObjectName(u"widget") + self.horizontalLayout = QHBoxLayout(self.widget) + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.horizontalLayout.setContentsMargins(0, 0, 0, 0) + self.label = QLabel(self.widget) + self.label.setObjectName(u"label") + + self.horizontalLayout.addWidget(self.label) + + self.lineEdit_startingid = QLineEdit(self.widget) + self.lineEdit_startingid.setObjectName(u"lineEdit_startingid") + self.lineEdit_startingid.setDragEnabled(False) + self.lineEdit_startingid.setReadOnly(False) + + self.horizontalLayout.addWidget(self.lineEdit_startingid) + + self.splitter.addWidget(self.widget) + self.layoutWidget = QWidget(self.splitter) + self.layoutWidget.setObjectName(u"layoutWidget") + self.horizontalLayout_2 = QHBoxLayout(self.layoutWidget) + self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") + self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) + self.label_2 = QLabel(self.layoutWidget) + self.label_2.setObjectName(u"label_2") + + self.horizontalLayout_2.addWidget(self.label_2) + + self.lineEdit_editor = QLineEdit(self.layoutWidget) + self.lineEdit_editor.setObjectName(u"lineEdit_editor") + + self.horizontalLayout_2.addWidget(self.lineEdit_editor) + + self.splitter.addWidget(self.layoutWidget) + self.layoutWidget_2 = QWidget(self.splitter) + self.layoutWidget_2.setObjectName(u"layoutWidget_2") + self.horizontalLayout_3 = QHBoxLayout(self.layoutWidget_2) + self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") + self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) + self.label_3 = QLabel(self.layoutWidget_2) + self.label_3.setObjectName(u"label_3") + + self.horizontalLayout_3.addWidget(self.label_3) + + self.lineEdit_origin = QLineEdit(self.layoutWidget_2) + self.lineEdit_origin.setObjectName(u"lineEdit_origin") + + self.horizontalLayout_3.addWidget(self.lineEdit_origin) + + self.splitter.addWidget(self.layoutWidget_2) + self.layoutWidget_3 = QWidget(self.splitter) + self.layoutWidget_3.setObjectName(u"layoutWidget_3") + self.horizontalLayout_4 = QHBoxLayout(self.layoutWidget_3) + self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") + self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0) + self.label_4 = QLabel(self.layoutWidget_3) + self.label_4.setObjectName(u"label_4") + + self.horizontalLayout_4.addWidget(self.label_4) + + self.lineEdit_suffix = QLineEdit(self.layoutWidget_3) + self.lineEdit_suffix.setObjectName(u"lineEdit_suffix") + self.lineEdit_suffix.setEnabled(False) + + self.horizontalLayout_4.addWidget(self.lineEdit_suffix) + + self.checkBox_suffix = QCheckBox(self.layoutWidget_3) + self.checkBox_suffix.setObjectName(u"checkBox_suffix") + + self.horizontalLayout_4.addWidget(self.checkBox_suffix) + + self.splitter.addWidget(self.layoutWidget_3) + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"\u6279\u91cf\u6536\u5f55\u65b0\u9898", None)) + self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u6536\u5f55\u65b0\u9898", None)) + self.label.setText(QCoreApplication.translate("Form", u"\u8d77\u59cbID", None)) + self.lineEdit_startingid.setInputMask("") + self.lineEdit_startingid.setPlaceholderText(QCoreApplication.translate("Form", u"\u6570\u5b57\u9898\u53f7(\u901a\u5e38\u662f10000n+1)", None)) + self.label_2.setText(QCoreApplication.translate("Form", u"\u7f16\u8f91\u8005", None)) + self.lineEdit_editor.setPlaceholderText(QCoreApplication.translate("Form", u"\u7f16\u8f91\u8005\u59d3\u540d", None)) + self.label_3.setText(QCoreApplication.translate("Form", u"\u6765\u6e90", None)) + self.lineEdit_origin.setText(QCoreApplication.translate("Form", u"\u81ea\u62df\u9898\u76ee", None)) + self.lineEdit_origin.setPlaceholderText(QCoreApplication.translate("Form", u"\u9898\u76ee\u6765\u6e90, \u901a\u5e38\u4e3a \u81ea\u62df\u9898\u76ee", None)) + self.label_4.setText(QCoreApplication.translate("Form", u"\u540e\u7f00", None)) + self.lineEdit_suffix.setText(QCoreApplication.translate("Form", u"\u8bd5\u9898", None)) + self.lineEdit_suffix.setPlaceholderText(QCoreApplication.translate("Form", u"\u901a\u5e38\u4e3a \u8bd5\u9898", None)) + self.checkBox_suffix.setText(QCoreApplication.translate("Form", u"\u4f7f\u7528\u540e\u7f00", None)) + # retranslateUi + diff --git a/工具v2/批量收录题目.py b/工具v2/批量收录题目.py index 52c5334d..1e66e0e3 100644 --- a/工具v2/批量收录题目.py +++ b/工具v2/批量收录题目.py @@ -1,20 +1,51 @@ -#修改起始id,出处,文件名 -starting_id = 30001 #起始id设置, 从这一个题号后的第一个空闲题号开始添加 20040124修改 -raworigin = "自拟题目" #题目来源的前缀(中缀在.tex文件中) -filename = r"临时文件\新题比对.tex" #题目的来源.tex文件 -editor = "毛培菁" #编辑者姓名 -IndexDescription = "" #设置是否使用后缀, 留空("")则不用后缀, 不留空则以所设字符串作为后缀起始词, 按.tex文件中的顺序编号 -idlistpath = r"文本文件\新题收录列表.txt" - +from PySide6.QtWidgets import QWidget, QApplication, QFileDialog +from Ui_批量收录题目 import Ui_Form from database_tools import * -problems = GenerateProblemListFromString2024(ReadTextFile(filename)) -pro_dict = load_dict(r"../题库0.3/Problems.json") -idlist = AddProblemstoDict2024(NextSpareID(starting_id,pro_dict),raworigin,problems,editor,IndexDescription,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}") +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(): + IndexDescription = self.lineEdit_suffix.text().strip() + else: + IndexDescription = "" + idlistpath = "文本文件/新题收录列表.txt" + problems = GenerateProblemListFromString2024(ReadTextFile(filename)) + pro_dict = load_dict("../题库0.3/Problems.json") + idlist = AddProblemstoDict2024(NextSpareID(starting_id,pro_dict),raworigin,problems,editor,IndexDescription,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() diff --git a/工具v2/批量收录题目.ui b/工具v2/批量收录题目.ui new file mode 100644 index 00000000..d72201f3 --- /dev/null +++ b/工具v2/批量收录题目.ui @@ -0,0 +1,147 @@ + + + Form + + + + 0 + 0 + 342 + 109 + + + + 批量收录新题 + + + + + 260 + 10 + 71 + 91 + + + + + true + + + + 收录新题 + + + + + + 10 + 10 + 241 + 88 + + + + Qt::Vertical + + + + + + + 起始ID + + + + + + + + + + false + + + false + + + 数字题号(通常是10000n+1) + + + + + + + + + + + 编辑者 + + + + + + + 编辑者姓名 + + + + + + + + + + + 来源 + + + + + + + 自拟题目 + + + 题目来源, 通常为 自拟题目 + + + + + + + + + + + 后缀 + + + + + + + false + + + 试题 + + + 通常为 试题 + + + + + + + 使用后缀 + + + + + + + + + + diff --git a/工具v2/批量收录题目old.py b/工具v2/批量收录题目old.py new file mode 100644 index 00000000..52c5334d --- /dev/null +++ b/工具v2/批量收录题目old.py @@ -0,0 +1,20 @@ +#修改起始id,出处,文件名 +starting_id = 30001 #起始id设置, 从这一个题号后的第一个空闲题号开始添加 20040124修改 +raworigin = "自拟题目" #题目来源的前缀(中缀在.tex文件中) +filename = r"临时文件\新题比对.tex" #题目的来源.tex文件 +editor = "毛培菁" #编辑者姓名 +IndexDescription = "" #设置是否使用后缀, 留空("")则不用后缀, 不留空则以所设字符串作为后缀起始词, 按.tex文件中的顺序编号 +idlistpath = r"文本文件\新题收录列表.txt" + +from database_tools import * + +problems = GenerateProblemListFromString2024(ReadTextFile(filename)) +pro_dict = load_dict(r"../题库0.3/Problems.json") +idlist = AddProblemstoDict2024(NextSpareID(starting_id,pro_dict),raworigin,problems,editor,IndexDescription,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}") + + + +