From de216100a084b84271794d945e32b5d278926006 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Sat, 2 Mar 2024 20:52:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BC=96=E8=BE=91=E9=A2=98?= =?UTF-8?q?=E7=9B=AE(latex,json)=E7=9A=84Qt=20widget=E5=B9=B6=E5=9C=A8Qt?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF,=20=E5=B7=A5=E5=85=B7=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=B8=8A=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/Qt面板.py | 3 +- 工具v2/Qt面板.ui | 18 ++----- 工具v2/Ui_Qt面板.py | 16 ++---- 工具v2/Ui_编辑题目信息.py | 103 ++++++++++++++++++++++++++++++++++++++ 工具v2/工具面板.py | 3 +- 工具v2/编辑题目信息.py | 50 ++++++++++++++++++ 工具v2/编辑题目信息.ui | 99 ++++++++++++++++++++++++++++++++++++ 7 files changed, 261 insertions(+), 31 deletions(-) create mode 100644 工具v2/Ui_编辑题目信息.py create mode 100644 工具v2/编辑题目信息.py create mode 100644 工具v2/编辑题目信息.ui diff --git a/工具v2/Qt面板.py b/工具v2/Qt面板.py index bfabbd1b..9d10c640 100644 --- a/工具v2/Qt面板.py +++ b/工具v2/Qt面板.py @@ -30,8 +30,7 @@ class MyWindow(QMainWindow,Ui_MainWindow): self.action_plsl.triggered.connect(lambda: run_command("批量收录题目",[])) self.action_tjgl.triggered.connect(lambda: run_command("添加关联题目",[])) self.action_tjzd.triggered.connect(lambda: run_command("修改metadata",["文本文件/metadata.txt"])) - self.action_LaTeXedit.triggered.connect(lambda: run_command("LaTeX编辑题目答案及提示",["latex编辑题目答案及提示.py"])) - self.action_jsonedit.triggered.connect(lambda: run_command("json编辑题目综合信息",["json编辑题目综合信息.py"])) + self.action_bjtm.triggered.connect(lambda: run_command("编辑题目信息",[])) self.action_xxdr.triggered.connect(lambda: run_command("获取小闲平台使用数据",[])) self.action_sddr.triggered.connect(lambda: run_command("手动统计结果导入",["临时文件/手动统计结果.txt"])) self.action_tkdr.triggered.connect(lambda: run_command("统考数据导入",["统考数据导入.py"])) diff --git a/工具v2/Qt面板.ui b/工具v2/Qt面板.ui index 8ad26b3a..9619c604 100644 --- a/工具v2/Qt面板.ui +++ b/工具v2/Qt面板.ui @@ -38,16 +38,9 @@ 维护 - - - 编辑题目 - - - - - + @@ -213,14 +206,9 @@ 多选转填空 - + - LaTeX - - - - - json + 编辑题目 diff --git a/工具v2/Ui_Qt面板.py b/工具v2/Ui_Qt面板.py index 2728ca66..d1e20924 100644 --- a/工具v2/Ui_Qt面板.py +++ b/工具v2/Ui_Qt面板.py @@ -68,10 +68,8 @@ class Ui_MainWindow(object): self.action_dqsz.setObjectName(u"action_dqsz") self.action_dxtk = QAction(MainWindow) self.action_dxtk.setObjectName(u"action_dxtk") - self.action_LaTeXedit = QAction(MainWindow) - self.action_LaTeXedit.setObjectName(u"action_LaTeXedit") - self.action_jsonedit = QAction(MainWindow) - self.action_jsonedit.setObjectName(u"action_jsonedit") + self.action_bjtm = QAction(MainWindow) + self.action_bjtm.setObjectName(u"action_bjtm") self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName(u"centralwidget") MainWindow.setCentralWidget(self.centralwidget) @@ -82,8 +80,6 @@ class Ui_MainWindow(object): self.menu_luru.setObjectName(u"menu_luru") self.menu_weihu = QMenu(self.menubar) self.menu_weihu.setObjectName(u"menu_weihu") - self.menu = QMenu(self.menu_weihu) - self.menu.setObjectName(u"menu") self.menu_shiyong = QMenu(self.menubar) self.menu_shiyong.setObjectName(u"menu_shiyong") self.menu_beikezu = QMenu(self.menubar) @@ -111,7 +107,7 @@ class Ui_MainWindow(object): self.menu_luru.addAction(self.action_tjgl) self.menu_weihu.addAction(self.action_tjzd) self.menu_weihu.addSeparator() - self.menu_weihu.addAction(self.menu.menuAction()) + self.menu_weihu.addAction(self.action_bjtm) self.menu_weihu.addSeparator() self.menu_weihu.addAction(self.action_xxdr) self.menu_weihu.addAction(self.action_sddr) @@ -124,8 +120,6 @@ class Ui_MainWindow(object): self.menu_weihu.addAction(self.action_hbsy) self.menu_weihu.addSeparator() self.menu_weihu.addAction(self.action_tjjc) - self.menu.addAction(self.action_LaTeXedit) - self.menu.addAction(self.action_jsonedit) self.menu_shiyong.addAction(self.action_sxth) self.menu_shiyong.addSeparator() self.menu_shiyong.addAction(self.action_xtby) @@ -170,11 +164,9 @@ class Ui_MainWindow(object): self.action_mtpx.setText(QCoreApplication.translate("MainWindow", u"mathpix\u9884\u5904\u7406", None)) self.action_dqsz.setText(QCoreApplication.translate("MainWindow", u"\u62ec\u53f7\u6570\u5b57\u53d8\u4e3a\u5e26\u5708\u6570\u5b57", None)) self.action_dxtk.setText(QCoreApplication.translate("MainWindow", u"\u591a\u9009\u8f6c\u586b\u7a7a", None)) - self.action_LaTeXedit.setText(QCoreApplication.translate("MainWindow", u"LaTeX", None)) - self.action_jsonedit.setText(QCoreApplication.translate("MainWindow", u"json", None)) + self.action_bjtm.setText(QCoreApplication.translate("MainWindow", u"\u7f16\u8f91\u9898\u76ee", None)) self.menu_luru.setTitle(QCoreApplication.translate("MainWindow", u"\u5f55\u5165", None)) self.menu_weihu.setTitle(QCoreApplication.translate("MainWindow", u"\u7ef4\u62a4", None)) - self.menu.setTitle(QCoreApplication.translate("MainWindow", u"\u7f16\u8f91\u9898\u76ee", None)) self.menu_shiyong.setTitle(QCoreApplication.translate("MainWindow", u"\u4f7f\u7528", None)) self.menu_beikezu.setTitle(QCoreApplication.translate("MainWindow", u"\u5907\u8bfe\u7ec4", None)) self.menu_latex.setTitle(QCoreApplication.translate("MainWindow", u"LaTeX\u4ee3\u7801\u76f8\u5173", None)) diff --git a/工具v2/Ui_编辑题目信息.py b/工具v2/Ui_编辑题目信息.py new file mode 100644 index 00000000..2951b525 --- /dev/null +++ b/工具v2/Ui_编辑题目信息.py @@ -0,0 +1,103 @@ +# -*- 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, QHBoxLayout, QLabel, QLineEdit, + QPushButton, QRadioButton, QSizePolicy, QVBoxLayout, + QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(390, 72) + self.pushButton_exec = QPushButton(Form) + self.pushButton_exec.setObjectName(u"pushButton_exec") + self.pushButton_exec.setGeometry(QRect(310, 10, 71, 51)) + font = QFont() + font.setBold(True) + self.pushButton_exec.setFont(font) + self.widget = QWidget(Form) + self.widget.setObjectName(u"widget") + self.widget.setGeometry(QRect(10, 10, 292, 54)) + self.horizontalLayout_3 = QHBoxLayout(self.widget) + self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") + self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) + self.verticalLayout_2 = QVBoxLayout() + self.verticalLayout_2.setObjectName(u"verticalLayout_2") + self.horizontalLayout = QHBoxLayout() + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.label = QLabel(self.widget) + self.label.setObjectName(u"label") + + self.horizontalLayout.addWidget(self.label) + + self.lineEdit_id = QLineEdit(self.widget) + self.lineEdit_id.setObjectName(u"lineEdit_id") + + self.horizontalLayout.addWidget(self.lineEdit_id) + + + self.verticalLayout_2.addLayout(self.horizontalLayout) + + self.horizontalLayout_2 = QHBoxLayout() + self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") + self.label_2 = QLabel(self.widget) + self.label_2.setObjectName(u"label_2") + + self.horizontalLayout_2.addWidget(self.label_2) + + self.lineEdit_editor = QLineEdit(self.widget) + self.lineEdit_editor.setObjectName(u"lineEdit_editor") + + self.horizontalLayout_2.addWidget(self.lineEdit_editor) + + + self.verticalLayout_2.addLayout(self.horizontalLayout_2) + + + self.horizontalLayout_3.addLayout(self.verticalLayout_2) + + self.verticalLayout = QVBoxLayout() + self.verticalLayout.setObjectName(u"verticalLayout") + self.radioButton_latex = QRadioButton(self.widget) + self.radioButton_latex.setObjectName(u"radioButton_latex") + + self.verticalLayout.addWidget(self.radioButton_latex) + + self.radioButton_json = QRadioButton(self.widget) + self.radioButton_json.setObjectName(u"radioButton_json") + + self.verticalLayout.addWidget(self.radioButton_json) + + + self.horizontalLayout_3.addLayout(self.verticalLayout) + + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"\u7f16\u8f91\u9898\u76ee\u4fe1\u606f", None)) + self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u5f00\u59cb\u7f16\u8f91", None)) + self.label.setText(QCoreApplication.translate("Form", u"\u5f85\u4fee\u6539ID", None)) + self.label_2.setText(QCoreApplication.translate("Form", u"\u7f16\u8f91\u8005", None)) + self.radioButton_latex.setText(QCoreApplication.translate("Form", u"LaTeX\u6a21\u5f0f", None)) + self.radioButton_json.setText(QCoreApplication.translate("Form", u"json\u6a21\u5f0f", None)) + # retranslateUi + diff --git a/工具v2/工具面板.py b/工具v2/工具面板.py index 3ed4999f..02639ff3 100644 --- a/工具v2/工具面板.py +++ b/工具v2/工具面板.py @@ -81,8 +81,7 @@ MaintainenceMenu = Menu(menubar, tearoff = False) menubar.add_cascade(label = "维护", menu = MaintainenceMenu) MaintainenceMenu.add_command(label = "批量添加字段数据", command = lambda: SetButton("修改metadata",["文本文件/metadata.txt"])) MaintainenceMenu.add_separator() -MaintainenceMenu.add_command(label = "LaTeX编辑题目答案及提示", command = lambda: SetButton("LaTeX编辑题目答案及提示",["latex编辑题目答案及提示.py"])) -MaintainenceMenu.add_command(label = "json编辑题目综合信息", command = lambda: SetButton("json编辑题目综合信息",["json编辑题目综合信息.py"])) +MaintainenceMenu.add_command(label = "编辑题目", command = lambda: SetButton("编辑题目信息",[])) MaintainenceMenu.add_separator() MaintainenceMenu.add_command(label = "合并使用记录并排序", command = lambda: SetButton("合并使用记录并排序",[])) MaintainenceMenu.add_separator() diff --git a/工具v2/编辑题目信息.py b/工具v2/编辑题目信息.py new file mode 100644 index 00000000..38dc4706 --- /dev/null +++ b/工具v2/编辑题目信息.py @@ -0,0 +1,50 @@ +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.radioButton_latex.setChecked(True) + self.pushButton_exec.clicked.connect(self.exec) + def exec(self): + id_string = self.lineEdit_id.text() + editor = self.lineEdit_editor.text() + prodictpath = "../题库0.3/Problems.json" + pro_dict = load_dict(prodictpath) + obj_dict = load_dict("../题库0.3/LessonObj.json") + pro_dict_raw_string = ReadTextFile(prodictpath) + configjson = BuildFullScheme + if self.radioButton_latex.isChecked(): + tempfilepath = "临时文件/problem_edit.tex" + edited = ModifyProblembyTeX(id_string,pro_dict,tempfilepath,editor) + else: + edited = jsonEditProblemMetadata(id_string,pro_dict,editor) + save_dict(pro_dict,prodictpath) + print(f"编辑过的题号: {edited}") + if edited != "无有效题号": + if not XeLaTeXTest(edited,pro_dict,obj_dict,configjson,templatepath="模板文件/讲义模板.txt",outdir = "临时文件",outfile = "problems_test.tex"): + SaveTextFile(pro_dict_raw_string,"../题库0.3/Problems.json") + print("编译失败, 题库文件退回原状") + else: + print("编译成功, 已汇入题库") + self.close() + + + + + + + + + + +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..a80628bb --- /dev/null +++ b/工具v2/编辑题目信息.ui @@ -0,0 +1,99 @@ + + + Form + + + + 0 + 0 + 390 + 72 + + + + 编辑题目信息 + + + + + 310 + 10 + 71 + 51 + + + + + true + + + + 开始编辑 + + + + + + 10 + 10 + 292 + 54 + + + + + + + + + + + 待修改ID + + + + + + + + + + + + + + 编辑者 + + + + + + + + + + + + + + + + LaTeX模式 + + + + + + + json模式 + + + + + + + + + + +