From c21a75fb3fad80ab9aff9cd3d46ec66f1567250e Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Sun, 3 Mar 2024 17:42:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8Qt=E9=87=8D=E5=86=99=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=9F=BA=E7=A1=80=E7=9F=A5=E8=AF=86=E6=A2=B3=E7=90=86?= =?UTF-8?q?=20=E5=8A=9F=E8=83=BD,=20=E5=B9=B6=E5=8A=A0=E5=85=A5=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/Qt面板.py | 2 +- 工具v2/Ui_新增基础知识梳理.py | 60 +++++++++++++++++++++++ 工具v2/工具面板.py | 2 +- 工具v2/新增基础知识梳理.py | 58 ++++++++++++++++++++++ 工具v2/新增基础知识梳理.ui | 91 +++++++++++++++++++++++++++++++++++ 5 files changed, 211 insertions(+), 2 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 198c0e23..f448a36d 100644 --- a/工具v2/Qt面板.py +++ b/工具v2/Qt面板.py @@ -37,7 +37,7 @@ class MyWindow(QMainWindow,Ui_MainWindow): self.action_dygg.triggered.connect(lambda: run_command("单元挂钩",["单元挂钩.py"])) self.action_tqda.triggered.connect(lambda: run_command("文件或文本框提取答案",[]))#已完成 self.action_hbsy.triggered.connect(lambda: run_command("合并使用记录并排序",[]))#已完成 - self.action_tjjc.triggered.connect(lambda: run_command("添加基础知识梳理",["添加基础知识梳理.py"])) + self.action_tjjc.triggered.connect(lambda: run_command("新增基础知识梳理",[]))#已完成 self.action_sxth.triggered.connect(lambda: run_command("关键字筛选题号",[]))#已完成 self.action_xtby.triggered.connect(lambda: run_command("指定题号编译pdf",[]))#已完成 self.action_sctp.triggered.connect(lambda: run_command("单一题号转为图片",[]))#已完成 diff --git a/工具v2/Ui_新增基础知识梳理.py b/工具v2/Ui_新增基础知识梳理.py new file mode 100644 index 00000000..a54b7be6 --- /dev/null +++ b/工具v2/Ui_新增基础知识梳理.py @@ -0,0 +1,60 @@ +# -*- 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, QLabel, QLineEdit, QPushButton, + QSizePolicy, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(400, 129) + self.label = QLabel(Form) + self.label.setObjectName(u"label") + self.label.setGeometry(QRect(10, 20, 91, 16)) + self.lineEdit_filepath = QLineEdit(Form) + self.lineEdit_filepath.setObjectName(u"lineEdit_filepath") + self.lineEdit_filepath.setGeometry(QRect(10, 40, 381, 20)) + self.lineEdit_filepath.setReadOnly(True) + self.pushButton_selectfilepath = QPushButton(Form) + self.pushButton_selectfilepath.setObjectName(u"pushButton_selectfilepath") + self.pushButton_selectfilepath.setGeometry(QRect(304, 10, 91, 24)) + self.label_2 = QLabel(Form) + self.label_2.setObjectName(u"label_2") + self.label_2.setGeometry(QRect(10, 70, 291, 51)) + self.pushButton_exec = QPushButton(Form) + self.pushButton_exec.setObjectName(u"pushButton_exec") + self.pushButton_exec.setGeometry(QRect(310, 70, 81, 51)) + font = QFont() + font.setBold(True) + self.pushButton_exec.setFont(font) + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"\u65b0\u589e\u57fa\u7840\u77e5\u8bc6\u68b3\u7406", None)) + self.label.setText(QCoreApplication.translate("Form", u"LaTeX\u6587\u4ef6\u4f4d\u7f6e", None)) + self.pushButton_selectfilepath.setText(QCoreApplication.translate("Form", u"\u9009\u62e9\u6587\u4ef6", None)) + self.label_2.setText(QCoreApplication.translate("Form", u"LaTeX\u6587\u4ef6\u4e2d\u6709\u4e00\u4e2aenumerate\u73af\u5883.\n" +"\u6bcf\u4e00\u4e2aitem\u540e\u9762\u6709\u4e00\u4e2a\u4e2d\u62ec\u53f7\u5305\u56f4\u7684\u4fe1\u606f, \u4e4b\u540e\u662f\u5185\u5bb9.\n" +"\u4f8b\u5982: \\item [K0101/K0101001B,K0101002B] \u5185\u5bb9", None)) + self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u6dfb\u52a0\u57fa\u7840\u77e5\u8bc6", None)) + # retranslateUi + diff --git a/工具v2/工具面板.py b/工具v2/工具面板.py index 308276e1..179ef811 100644 --- a/工具v2/工具面板.py +++ b/工具v2/工具面板.py @@ -132,7 +132,7 @@ BKMenu.add_command(label = "录入答题纸对应信息", command = lambda: SetB BKMenu.add_command(label = "讲义生成", command = lambda: SetButton("讲义生成",["讲义生成.py"])) BKMenu.add_command(label = "系列讲义生成", command = lambda: SetButton("系列讲义生成",[])) BKMenu.add_separator() -BKMenu.add_command(label = "添加基础知识梳理", command = lambda: SetButton("添加基础知识梳理",["添加基础知识梳理.py"])) +BKMenu.add_command(label = "添加基础知识梳理", command = lambda: SetButton("新增基础知识梳理",[])) # BKMenu.add_command(label = "题号清单生成", command = lambda: SetButton("题号清单生成",1,["题号清单生成.py"])) # BKMenu.add_command(label = "已用题号剔除", command = lambda: SetButton("已用题号剔除",1,["已用题号剔除.py"])) # BKMenu.add_command(label = "寻找未赋答案题目", command = lambda: SetButton("寻找未赋答案题目",1,["寻找未赋答案题目.py"])) diff --git a/工具v2/新增基础知识梳理.py b/工具v2/新增基础知识梳理.py new file mode 100644 index 00000000..5256d29e --- /dev/null +++ b/工具v2/新增基础知识梳理.py @@ -0,0 +1,58 @@ +from PySide6.QtWidgets import QWidget, QApplication, QFileDialog +from Ui_新增基础知识梳理 import Ui_Form +import os +from database_tools import * + +class MyWindow(QWidget,Ui_Form): + def __init__(self): + super().__init__() + self.setupUi(self) + self.bind() + def bind(self): + self.pushButton_exec.setDisabled(True) + self.pushButton_selectfilepath.clicked.connect(self.selectfilepath) + self.pushButton_exec.clicked.connect(self.exec) + def selectfilepath(self): + self.filepath = QFileDialog.getOpenFileName(self,"选择.tex文件",os.getcwd(),"tex文件(*.tex);;所有文件(*)")[0] + self.lineEdit_filepath.setText(self.filepath) + self.pushButton_exec.setEnabled(True) + def exec(self): + bkdatajsonpath = r"../题库0.3/BasicKnowledge.json" # 知识梳理数据库路径 + basicknowledge_dict = load_dict(bkdatajsonpath) + bkdata_raw = ReadTextFile(self.filepath) + bkdatabody = re.findall(r"\\begin\{enumerate\}([\s\S]*?)\\end\{enumerate\}",bkdata_raw)[0].strip().split("\\item") + bkdata = [line.strip() for line in bkdatabody if "[" in line and "]" in line] + + + currentid = int(max(basicknowledge_dict)[1:])+1 + + for line in bkdata: + if not line.strip() == "": + id = "B" + str(currentid).zfill(5) + pos = line.index("]") + head = line[1:pos] + content = line[pos+1:].strip() + lesson,objs = head.split("/") + obj_list = objs.split(",") + print(lesson,obj_list,content) + basicknowledge_dict[id] = {} + basicknowledge_dict[id]["lesson"] = lesson + basicknowledge_dict[id]["objs"] = obj_list + basicknowledge_dict[id]["content"] = content + currentid += 1 + + save_dict(basicknowledge_dict,bkdatajsonpath) + print("已录入完成") + + + + + + + +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..68cc60fe --- /dev/null +++ b/工具v2/新增基础知识梳理.ui @@ -0,0 +1,91 @@ + + + Form + + + + 0 + 0 + 400 + 129 + + + + 新增基础知识梳理 + + + + + 10 + 20 + 91 + 16 + + + + LaTeX文件位置 + + + + + + 10 + 40 + 381 + 20 + + + + true + + + + + + 304 + 10 + 91 + 24 + + + + 选择文件 + + + + + + 10 + 70 + 291 + 51 + + + + LaTeX文件中有一个enumerate环境. +每一个item后面有一个中括号包围的信息, 之后是内容. +例如: \item [K0101/K0101001B,K0101002B] 内容 + + + + + + 310 + 70 + 81 + 51 + + + + + true + + + + 添加基础知识 + + + + + +