LaTeX代码转换功能迁移完毕
This commit is contained in:
parent
80ebf60990
commit
12ffd17e28
|
|
@ -0,0 +1,96 @@
|
|||
# -*- 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, QPlainTextEdit, QPushButton,
|
||||
QRadioButton, QSizePolicy, QVBoxLayout, QWidget)
|
||||
|
||||
class Ui_Form(object):
|
||||
def setupUi(self, Form):
|
||||
if not Form.objectName():
|
||||
Form.setObjectName(u"Form")
|
||||
Form.resize(760, 490)
|
||||
self.plainTextEdit_origin = QPlainTextEdit(Form)
|
||||
self.plainTextEdit_origin.setObjectName(u"plainTextEdit_origin")
|
||||
self.plainTextEdit_origin.setGeometry(QRect(10, 30, 310, 430))
|
||||
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(430, 10, 54, 16))
|
||||
self.plainTextEdit_dest = QPlainTextEdit(Form)
|
||||
self.plainTextEdit_dest.setObjectName(u"plainTextEdit_dest")
|
||||
self.plainTextEdit_dest.setGeometry(QRect(430, 30, 310, 430))
|
||||
self.plainTextEdit_dest.setAutoFillBackground(False)
|
||||
self.plainTextEdit_dest.setReadOnly(True)
|
||||
self.pushButton_convert = QPushButton(Form)
|
||||
self.pushButton_convert.setObjectName(u"pushButton_convert")
|
||||
self.pushButton_convert.setGeometry(QRect(330, 280, 91, 71))
|
||||
font = QFont()
|
||||
font.setBold(True)
|
||||
self.pushButton_convert.setFont(font)
|
||||
self.layoutWidget = QWidget(Form)
|
||||
self.layoutWidget.setObjectName(u"layoutWidget")
|
||||
self.layoutWidget.setGeometry(QRect(330, 100, 97, 126))
|
||||
self.verticalLayout = QVBoxLayout(self.layoutWidget)
|
||||
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.radioButton_mathpix = QRadioButton(self.layoutWidget)
|
||||
self.radioButton_mathpix.setObjectName(u"radioButton_mathpix")
|
||||
|
||||
self.verticalLayout.addWidget(self.radioButton_mathpix)
|
||||
|
||||
self.radioButton_textcircled = QRadioButton(self.layoutWidget)
|
||||
self.radioButton_textcircled.setObjectName(u"radioButton_textcircled")
|
||||
|
||||
self.verticalLayout.addWidget(self.radioButton_textcircled)
|
||||
|
||||
self.radioButton_multiple = QRadioButton(self.layoutWidget)
|
||||
self.radioButton_multiple.setObjectName(u"radioButton_multiple")
|
||||
|
||||
self.verticalLayout.addWidget(self.radioButton_multiple)
|
||||
|
||||
self.radioButton_puctuations = QRadioButton(self.layoutWidget)
|
||||
self.radioButton_puctuations.setObjectName(u"radioButton_puctuations")
|
||||
|
||||
self.verticalLayout.addWidget(self.radioButton_puctuations)
|
||||
|
||||
self.radioButton_answers = QRadioButton(self.layoutWidget)
|
||||
self.radioButton_answers.setObjectName(u"radioButton_answers")
|
||||
|
||||
self.verticalLayout.addWidget(self.radioButton_answers)
|
||||
|
||||
|
||||
self.retranslateUi(Form)
|
||||
|
||||
QMetaObject.connectSlotsByName(Form)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, Form):
|
||||
Form.setWindowTitle(QCoreApplication.translate("Form", u"\u6587\u672c\u8f6c\u6362\u5904\u7406", None))
|
||||
self.plainTextEdit_origin.setPlaceholderText(QCoreApplication.translate("Form", u"\u5c06\u6e90\u6587\u672c \u7c98\u8d34 \u5728\u8fd9\u4e2a\u6587\u672c\u6846\u5185", None))
|
||||
self.label.setText(QCoreApplication.translate("Form", u"\u6e90\u6587\u672c", None))
|
||||
self.label_2.setText(QCoreApplication.translate("Form", u"\u76ee\u6807\u6587\u672c", None))
|
||||
self.plainTextEdit_dest.setPlaceholderText(QCoreApplication.translate("Form", u"\u6309 \u8f6c\u6362 \u4ee5\u83b7\u5f97\u76ee\u6807\u6587\u672c", None))
|
||||
self.pushButton_convert.setText(QCoreApplication.translate("Form", u"\u8f6c\u6362", None))
|
||||
self.radioButton_mathpix.setText(QCoreApplication.translate("Form", u"Mathpix", None))
|
||||
self.radioButton_textcircled.setText(QCoreApplication.translate("Form", u"\u5706\u5708\u6570\u5b57", None))
|
||||
self.radioButton_multiple.setText(QCoreApplication.translate("Form", u"\u591a\u9009\u8f6c\u586b\u7a7a", None))
|
||||
self.radioButton_puctuations.setText(QCoreApplication.translate("Form", u"\u6807\u70b9\u8f6c\u534a\u89d2", None))
|
||||
self.radioButton_answers.setText(QCoreApplication.translate("Form", u"\u5df2\u6709\u7b54\u6848\u6807\u7ea2", None))
|
||||
# retranslateUi
|
||||
|
||||
|
|
@ -3,6 +3,7 @@ from Ui_tool_panel import Ui_MainWindow
|
|||
from PySide6.QtCore import Signal
|
||||
from 寻找空闲题号 import MyWindow_kxth
|
||||
from 生成直方图代码 import MyWindow_hist
|
||||
from 文本转换处理 import MyWindow_wbzh
|
||||
from database_tools_2 import *
|
||||
|
||||
class MyWindow(QMainWindow,Ui_MainWindow):
|
||||
|
|
@ -19,20 +20,22 @@ class MyWindow(QMainWindow,Ui_MainWindow):
|
|||
self.pushButton_tikutest.clicked.connect(self.SelectTIKUTEST) #以上为设置当前数据库的两个按钮
|
||||
|
||||
self.layout_kxth = QVBoxLayout(self.tab_kxth)
|
||||
self.tab_kxth = MyWindow_kxth(self.database)
|
||||
self.layout_kxth.addWidget(self.tab_kxth) #以上三行为初始化“空闲题号”tab
|
||||
|
||||
self.kxth = MyWindow_kxth(self.database)
|
||||
self.layout_kxth.addWidget(self.kxth) #以上三行为初始化“空闲题号”tab
|
||||
|
||||
|
||||
self.layout_wbzh = QVBoxLayout(self.tab_wbzh)
|
||||
self.wbzh = MyWindow_wbzh()
|
||||
self.layout_wbzh.addWidget(self.wbzh) #以上三行为初始化“LaTeX代码转换”tab
|
||||
|
||||
self.layout_hist = QVBoxLayout(self.tab_hist)
|
||||
self.tab_hist = MyWindow_hist()
|
||||
self.layout_hist.addWidget(self.tab_hist) #以上三行为初始化“生成直方图代码”tab
|
||||
self.hist = MyWindow_hist()
|
||||
self.layout_hist.addWidget(self.hist) #以上三行为初始化“生成直方图代码”tab
|
||||
|
||||
|
||||
|
||||
for func in [
|
||||
self.tab_kxth.setdbname
|
||||
self.kxth.setdbname
|
||||
]: #在列表中的tab里传送数据库名的连接
|
||||
self.sendDBname.connect(func)
|
||||
def sendValue(self):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
|
||||
from Ui_文本转换处理 import Ui_Form
|
||||
from database_tools_2 import *
|
||||
|
||||
class MyWindow_wbzh(QWidget,Ui_Form):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setupUi(self)
|
||||
self.bind()
|
||||
def bind(self):
|
||||
self.radioButton_mathpix.setChecked(True)
|
||||
self.pushButton_convert.clicked.connect(self.exec)
|
||||
def exec(self):
|
||||
raw_string = self.plainTextEdit_origin.toPlainText()
|
||||
if self.radioButton_mathpix.isChecked():
|
||||
dest_string = RefineMathpix(raw_string)
|
||||
elif self.radioButton_textcircled.isChecked():
|
||||
dest_string = re.sub(r"\((\d)\)",lambda x: "\\textcircled{"+x.group(1)+"}",raw_string) #替换所有的小括号包围的单个数字为圆圈包围的
|
||||
dest_string = re.sub(r"\$\\textcircled\{\\scriptsize\{(\d)\}\}",lambda x: "\\textcircled{"+x.group(1)+"}$",dest_string)
|
||||
dest_string = re.sub(r"\\textcircled\{\\scriptsize\{(\d)\}\}",lambda x: "\\textcircled{"+x.group(1)+"}",dest_string)
|
||||
elif self.radioButton_multiple.isChecked():
|
||||
try:
|
||||
dest_string = MultiplechoicetoBlankFilling(raw_string)
|
||||
except:
|
||||
dest_string = "转换失败"
|
||||
elif self.radioButton_puctuations.isChecked():
|
||||
dest_string = RefinePunctuations(raw_string)
|
||||
elif self.radioButton_answers.isChecked():
|
||||
self.pro_dict = load_dict("../题库0.3/Problems.json")
|
||||
dest_string = PaintRedAnswers(raw_string,self.pro_dict)
|
||||
self.plainTextEdit_dest.setPlainText(dest_string)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication([])
|
||||
windows = MyWindow()
|
||||
windows.show()
|
||||
app.exec()
|
||||
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>760</width>
|
||||
<height>490</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>文本转换处理</string>
|
||||
</property>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_origin">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>310</width>
|
||||
<height>430</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>将源文本 粘贴 在这个文本框内</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>54</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>源文本</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>430</x>
|
||||
<y>10</y>
|
||||
<width>54</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>目标文本</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_dest">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>430</x>
|
||||
<y>30</y>
|
||||
<width>310</width>
|
||||
<height>430</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>按 转换 以获得目标文本</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_convert">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>280</y>
|
||||
<width>91</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>转换</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>100</y>
|
||||
<width>97</width>
|
||||
<height>126</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_mathpix">
|
||||
<property name="text">
|
||||
<string>Mathpix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_textcircled">
|
||||
<property name="text">
|
||||
<string>圆圈数字</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_multiple">
|
||||
<property name="text">
|
||||
<string>多选转填空</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_puctuations">
|
||||
<property name="text">
|
||||
<string>标点转半角</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_answers">
|
||||
<property name="text">
|
||||
<string>已有答案标红</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue