Qt 重写 单元挂钩 功能
This commit is contained in:
parent
d6b7b8a002
commit
9f1d5efad0
66
工具v2/单元挂钩.py
66
工具v2/单元挂钩.py
|
|
@ -1,27 +1,49 @@
|
|||
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
|
||||
from Ui_单元挂钩 import Ui_Form
|
||||
from database_tools import *
|
||||
|
||||
pro_dict = load_dict("../题库0.3/problems.json")
|
||||
configjson = load_dict("文本文件/config.json")["单元挂钩.py"]
|
||||
class MyWindow(QWidget,Ui_Form):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setupUi(self)
|
||||
self.bind()
|
||||
def bind(self):
|
||||
self.radioButton_phase1.setChecked(True)
|
||||
self.pushButton_exec.clicked.connect(self.exec)
|
||||
|
||||
def exec(self):
|
||||
pro_dict = load_dict("../题库0.3/problems.json")
|
||||
|
||||
if str(configjson["阶段"]).strip() == "1":
|
||||
idexp = configjson["题号表达式"]
|
||||
if idexp.strip() == "":
|
||||
idlist = unUnitted(pro_dict)
|
||||
else:
|
||||
idlist = generate_number_set(idexp)
|
||||
latex_body,tagrec = AutoAssignTagNotoLaTeX(idlist,pro_dict)
|
||||
latex_raw = ReadTextFile("模板文件/讲义模板.txt")
|
||||
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,("待检查单元",latex_body))
|
||||
SaveTextFile(tagrec,"临时文件/单元对应.txt")
|
||||
SaveTextFile(latex_data,"临时文件/待检查单元.tex")
|
||||
if XeLaTeXCompile("临时文件","待检查单元.tex") == True:
|
||||
print("处理成功.")
|
||||
os.system("code 临时文件/单元对应.txt 临时文件/待检查单元.pdf")
|
||||
else:
|
||||
print("处理失败.")
|
||||
elif str(configjson["阶段"]).strip() == "2":
|
||||
output = UnitRectoMetadataText(ReadTextFile("临时文件/单元对应.txt"))
|
||||
SaveTextFile(output,"文本文件/metadata.txt")
|
||||
os.system("code 文本文件/metadata.txt")
|
||||
if self.radioButton_phase1.isChecked():
|
||||
idexp = self.lineEdit_ids.text()
|
||||
if idexp.strip() == "":
|
||||
idlist = unUnitted(pro_dict)
|
||||
else:
|
||||
idlist = generate_number_set(idexp)
|
||||
latex_body,tagrec = AutoAssignTagNotoLaTeX(idlist,pro_dict)
|
||||
latex_raw = ReadTextFile("模板文件/讲义模板.txt")
|
||||
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,("待检查单元",latex_body))
|
||||
SaveTextFile(tagrec,"临时文件/单元对应.txt")
|
||||
SaveTextFile(latex_data,"临时文件/待检查单元.tex")
|
||||
if XeLaTeXCompile("临时文件","待检查单元.tex") == True:
|
||||
print("处理成功.")
|
||||
os.system("code 临时文件/单元对应.txt 临时文件/待检查单元.pdf")
|
||||
else:
|
||||
print("处理失败.")
|
||||
elif self.radioButton_phase2.isChecked():
|
||||
output = UnitRectoMetadataText(ReadTextFile("临时文件/单元对应.txt"))
|
||||
SaveTextFile(output,"文本文件/metadata.txt")
|
||||
os.system("code 文本文件/metadata.txt")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication([])
|
||||
windows = MyWindow()
|
||||
windows.show()
|
||||
app.exec()
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
<?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>400</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>单元挂钩</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>54</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>题号</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_phase2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>90</y>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>收录单元信息至metadata阶段</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_ids">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>271</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>输入题号, 留空表示针对所有没有对应单元的题目</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_exec">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>10</y>
|
||||
<width>71</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>运行</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_phase1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>141</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>自适应赋予单元信息</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
from database_tools import *
|
||||
|
||||
pro_dict = load_dict("../题库0.3/problems.json")
|
||||
configjson = load_dict("文本文件/config.json")["单元挂钩.py"]
|
||||
|
||||
if str(configjson["阶段"]).strip() == "1":
|
||||
idexp = configjson["题号表达式"]
|
||||
if idexp.strip() == "":
|
||||
idlist = unUnitted(pro_dict)
|
||||
else:
|
||||
idlist = generate_number_set(idexp)
|
||||
latex_body,tagrec = AutoAssignTagNotoLaTeX(idlist,pro_dict)
|
||||
latex_raw = ReadTextFile("模板文件/讲义模板.txt")
|
||||
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,("待检查单元",latex_body))
|
||||
SaveTextFile(tagrec,"临时文件/单元对应.txt")
|
||||
SaveTextFile(latex_data,"临时文件/待检查单元.tex")
|
||||
if XeLaTeXCompile("临时文件","待检查单元.tex") == True:
|
||||
print("处理成功.")
|
||||
os.system("code 临时文件/单元对应.txt 临时文件/待检查单元.pdf")
|
||||
else:
|
||||
print("处理失败.")
|
||||
elif str(configjson["阶段"]).strip() == "2":
|
||||
output = UnitRectoMetadataText(ReadTextFile("临时文件/单元对应.txt"))
|
||||
SaveTextFile(output,"文本文件/metadata.txt")
|
||||
os.system("code 文本文件/metadata.txt")
|
||||
|
||||
|
||||
Reference in New Issue