From e871c1f619d1c56c57c3e21dab0320b5c6be5e26 Mon Sep 17 00:00:00 2001 From: wangweiye7840 Date: Tue, 16 Apr 2024 11:50:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E7=AD=94=E6=A1=88=20?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E8=87=B3=20=E5=B7=A5=E5=85=B7v3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v3/Ui_文件或文本框提取答案.py | 84 +++++++++++++++ 工具v3/文件或文本框提取答案.py | 56 ++++++++++ 工具v3/文件或文本框提取答案.ui | 174 ++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 工具v3/Ui_文件或文本框提取答案.py create mode 100644 工具v3/文件或文本框提取答案.py create mode 100644 工具v3/文件或文本框提取答案.ui diff --git a/工具v3/Ui_文件或文本框提取答案.py b/工具v3/Ui_文件或文本框提取答案.py new file mode 100644 index 00000000..a785dd18 --- /dev/null +++ b/工具v3/Ui_文件或文本框提取答案.py @@ -0,0 +1,84 @@ +# -*- 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, QPlainTextEdit, + QPushButton, QRadioButton, QSizePolicy, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(690, 421) + self.plainTextEdit_rawString = QPlainTextEdit(Form) + self.plainTextEdit_rawString.setObjectName(u"plainTextEdit_rawString") + self.plainTextEdit_rawString.setGeometry(QRect(10, 80, 311, 331)) + self.lineEdit_filepath = QLineEdit(Form) + self.lineEdit_filepath.setObjectName(u"lineEdit_filepath") + self.lineEdit_filepath.setGeometry(QRect(10, 30, 331, 20)) + self.lineEdit_filepath.setReadOnly(True) + self.label = QLabel(Form) + self.label.setObjectName(u"label") + self.label.setGeometry(QRect(10, 10, 54, 16)) + self.label_2 = QLabel(Form) + self.label_2.setObjectName(u"label_2") + self.label_2.setGeometry(QRect(10, 60, 101, 16)) + self.lineEdit_2 = QLineEdit(Form) + self.lineEdit_2.setObjectName(u"lineEdit_2") + self.lineEdit_2.setGeometry(QRect(462, 30, 211, 20)) + self.label_3 = QLabel(Form) + self.label_3.setObjectName(u"label_3") + self.label_3.setGeometry(QRect(460, 10, 54, 16)) + self.radioButton_text = QRadioButton(Form) + self.radioButton_text.setObjectName(u"radioButton_text") + self.radioButton_text.setGeometry(QRect(580, 70, 95, 20)) + self.radioButton_file = QRadioButton(Form) + self.radioButton_file.setObjectName(u"radioButton_file") + self.radioButton_file.setGeometry(QRect(580, 100, 95, 20)) + self.pushButton_selectfilepath = QPushButton(Form) + self.pushButton_selectfilepath.setObjectName(u"pushButton_selectfilepath") + self.pushButton_selectfilepath.setGeometry(QRect(350, 30, 101, 24)) + self.label_4 = QLabel(Form) + self.label_4.setObjectName(u"label_4") + self.label_4.setGeometry(QRect(330, 60, 91, 16)) + self.plainTextEdit_ans = QPlainTextEdit(Form) + self.plainTextEdit_ans.setObjectName(u"plainTextEdit_ans") + self.plainTextEdit_ans.setGeometry(QRect(330, 80, 241, 331)) + self.pushButton_exec = QPushButton(Form) + self.pushButton_exec.setObjectName(u"pushButton_exec") + self.pushButton_exec.setGeometry(QRect(580, 130, 101, 281)) + 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"\u6587\u4ef6\u6216\u6587\u672c\u6846\u63d0\u53d6\u7b54\u6848", None)) + self.label.setText(QCoreApplication.translate("Form", u"\u6587\u4ef6\u8def\u5f84", None)) + self.label_2.setText(QCoreApplication.translate("Form", u"\u542b\u7b54\u6848\u7684\u6e90\u4ee3\u7801", None)) + self.lineEdit_2.setText(QCoreApplication.translate("Form", u"\u7b54\u6848: \\textcolor{blue}{", None)) + self.label_3.setText(QCoreApplication.translate("Form", u"\u7b54\u6848\u524d\u7f00", None)) + self.radioButton_text.setText(QCoreApplication.translate("Form", u"\u6587\u672c\u6846\u751f\u6210", None)) + self.radioButton_file.setText(QCoreApplication.translate("Form", u"\u6587\u4ef6\u751f\u6210", None)) + self.pushButton_selectfilepath.setText(QCoreApplication.translate("Form", u"\u9009\u62e9\u6587\u4ef6\u8def\u5f84", None)) + self.label_4.setText(QCoreApplication.translate("Form", u"\u7b54\u6848metadata", None)) + self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u63d0\u53d6\u7b54\u6848", None)) + # retranslateUi + diff --git a/工具v3/文件或文本框提取答案.py b/工具v3/文件或文本框提取答案.py new file mode 100644 index 00000000..44f92a55 --- /dev/null +++ b/工具v3/文件或文本框提取答案.py @@ -0,0 +1,56 @@ +from PySide6.QtWidgets import QWidget, QApplication, QFileDialog +from Ui_文件或文本框提取答案 import Ui_Form +import os +from database_tools_2 import * + + +class MyWindow(QWidget,Ui_Form): + def __init__(self): + super().__init__() + self.setupUi(self) + self.bind() + + def bind(self): + self.radioButton_text.setChecked(True) + self.textlayout() + self.radioButton_text.clicked.connect(self.textlayout) + self.radioButton_file.clicked.connect(self.filelayout) + self.pushButton_selectfilepath.clicked.connect(self.selectfilepath) + self.pushButton_exec.clicked.connect(self.exec) + def textlayout(self): + self.pushButton_selectfilepath.setDisabled(True) + self.lineEdit_filepath.setDisabled(True) + self.plainTextEdit_rawString.setEnabled(True) + def filelayout(self): + self.pushButton_selectfilepath.setEnabled(True) + self.lineEdit_filepath.setEnabled(True) + self.plainTextEdit_rawString.setDisabled(True) + def selectfilepath(self): + self.filepath = QFileDialog.getOpenFileName(self,"选择.tex文件",os.getcwd(),"tex文件(*.tex);;所有文件(*)")[0] + self.lineEdit_filepath.setText(self.filepath) + def exec(self): + if self.radioButton_text.isChecked(): + data = self.plainTextEdit_rawString.toPlainText() + else: + data = ReadTextFile(self.filepath) + print(self.lineEdit_2.text()) + anslist = generateAnswerList(data,self.lineEdit_2.text()) + + output = "ans\n\n" + for id,ans in anslist: + if not ans == "暂无答案": + output += f"{id}\n{ans}\n\n" + + self.plainTextEdit_ans.setPlainText(output) + + + + + + +if __name__ == '__main__': + app = QApplication([]) + windows = MyWindow() + windows.show() + app.exec() + diff --git a/工具v3/文件或文本框提取答案.ui b/工具v3/文件或文本框提取答案.ui new file mode 100644 index 00000000..b4b047ba --- /dev/null +++ b/工具v3/文件或文本框提取答案.ui @@ -0,0 +1,174 @@ + + + Form + + + + 0 + 0 + 690 + 421 + + + + 文件或文本框提取答案 + + + + + 10 + 80 + 311 + 331 + + + + + + + 10 + 30 + 331 + 20 + + + + true + + + + + + 10 + 10 + 54 + 16 + + + + 文件路径 + + + + + + 10 + 60 + 101 + 16 + + + + 含答案的源代码 + + + + + + 462 + 30 + 211 + 20 + + + + 答案: \textcolor{blue}{ + + + + + + 460 + 10 + 54 + 16 + + + + 答案前缀 + + + + + + 580 + 70 + 95 + 20 + + + + 文本框生成 + + + + + + 580 + 100 + 95 + 20 + + + + 文件生成 + + + + + + 350 + 30 + 101 + 24 + + + + 选择文件路径 + + + + + + 330 + 60 + 91 + 16 + + + + 答案metadata + + + + + + 330 + 80 + 241 + 331 + + + + + + + 580 + 130 + 101 + 281 + + + + + true + + + + 提取答案 + + + + + +