guipanel基本完成
This commit is contained in:
parent
724da97e91
commit
8d87bda99b
|
|
@ -61,6 +61,9 @@ class Ui_Form(object):
|
||||||
self.pushButton_exec = QPushButton(Form)
|
self.pushButton_exec = QPushButton(Form)
|
||||||
self.pushButton_exec.setObjectName(u"pushButton_exec")
|
self.pushButton_exec.setObjectName(u"pushButton_exec")
|
||||||
self.pushButton_exec.setGeometry(QRect(20, 460, 75, 48))
|
self.pushButton_exec.setGeometry(QRect(20, 460, 75, 48))
|
||||||
|
font = QFont()
|
||||||
|
font.setBold(True)
|
||||||
|
self.pushButton_exec.setFont(font)
|
||||||
self.pushButton_undo = QPushButton(Form)
|
self.pushButton_undo = QPushButton(Form)
|
||||||
self.pushButton_undo.setObjectName(u"pushButton_undo")
|
self.pushButton_undo.setObjectName(u"pushButton_undo")
|
||||||
self.pushButton_undo.setGeometry(QRect(20, 370, 75, 24))
|
self.pushButton_undo.setGeometry(QRect(20, 370, 75, 24))
|
||||||
|
|
@ -90,9 +93,13 @@ class Ui_Form(object):
|
||||||
self.label_3.setGeometry(QRect(120, 440, 91, 16))
|
self.label_3.setGeometry(QRect(120, 440, 91, 16))
|
||||||
self.lcdNumber_resCount = QLCDNumber(Form)
|
self.lcdNumber_resCount = QLCDNumber(Form)
|
||||||
self.lcdNumber_resCount.setObjectName(u"lcdNumber_resCount")
|
self.lcdNumber_resCount.setObjectName(u"lcdNumber_resCount")
|
||||||
self.lcdNumber_resCount.setGeometry(QRect(220, 460, 161, 51))
|
self.lcdNumber_resCount.setGeometry(QRect(120, 460, 161, 51))
|
||||||
self.lcdNumber_resCount.setDigitCount(6)
|
self.lcdNumber_resCount.setDigitCount(6)
|
||||||
self.lcdNumber_resCount.setProperty("value", 0.000000000000000)
|
self.lcdNumber_resCount.setProperty("value", 0.000000000000000)
|
||||||
|
self.pushButton_savebuild = QPushButton(Form)
|
||||||
|
self.pushButton_savebuild.setObjectName(u"pushButton_savebuild")
|
||||||
|
self.pushButton_savebuild.setGeometry(QRect(300, 440, 81, 71))
|
||||||
|
self.pushButton_savebuild.setFont(font)
|
||||||
|
|
||||||
self.retranslateUi(Form)
|
self.retranslateUi(Form)
|
||||||
|
|
||||||
|
|
@ -120,5 +127,6 @@ class Ui_Form(object):
|
||||||
self.checkBox_not.setText(QCoreApplication.translate("Form", u"\u9009\u4e2d\u8868\u793a\u4e0d\u5305\u542b", None))
|
self.checkBox_not.setText(QCoreApplication.translate("Form", u"\u9009\u4e2d\u8868\u793a\u4e0d\u5305\u542b", None))
|
||||||
self.label_2.setText(QCoreApplication.translate("Form", u"\u8f93\u5165\u6761\u4ef6, \u7528\",\"\u5206\u9694\u8868\u793a\"\u6216\"", None))
|
self.label_2.setText(QCoreApplication.translate("Form", u"\u8f93\u5165\u6761\u4ef6, \u7528\",\"\u5206\u9694\u8868\u793a\"\u6216\"", None))
|
||||||
self.label_3.setText(QCoreApplication.translate("Form", u"\u7b5b\u9009\u7ed3\u679c\u6570\u76ee:", None))
|
self.label_3.setText(QCoreApplication.translate("Form", u"\u7b5b\u9009\u7ed3\u679c\u6570\u76ee:", None))
|
||||||
|
self.pushButton_savebuild.setText(QCoreApplication.translate("Form", u"\u4fdd\u5b58\u548c\u7f16\u8bd1", None))
|
||||||
# retranslateUi
|
# retranslateUi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from PySide6.QtWidgets import QWidget, QApplication, QLineEdit, QVBoxLayout
|
from PySide6.QtWidgets import QWidget, QApplication, QLineEdit
|
||||||
from Ui_题号筛选器 import Ui_Form
|
from Ui_题号筛选器 import Ui_Form
|
||||||
from database_tools import *
|
from database_tools import *
|
||||||
|
|
||||||
|
|
@ -7,8 +7,8 @@ class MyWindow(QWidget,Ui_Form):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.conditions = []
|
self.conditions = []
|
||||||
pro_dict = load_dict("../题库0.3/Problems.json")
|
self.pro_dict = load_dict("../题库0.3/Problems.json")
|
||||||
self.lcdNumber_resCount.display(len(pro_dict))
|
self.lcdNumber_resCount.display(len(self.pro_dict))
|
||||||
self.bind()
|
self.bind()
|
||||||
|
|
||||||
def bind(self):
|
def bind(self):
|
||||||
|
|
@ -25,6 +25,8 @@ class MyWindow(QWidget,Ui_Form):
|
||||||
self.pushButton_remark.clicked.connect(lambda: self.add_content("remark"))
|
self.pushButton_remark.clicked.connect(lambda: self.add_content("remark"))
|
||||||
self.pushButton_undo.clicked.connect(self.undolast)
|
self.pushButton_undo.clicked.connect(self.undolast)
|
||||||
self.pushButton_clearAll.clicked.connect(self.clearConditions)
|
self.pushButton_clearAll.clicked.connect(self.clearConditions)
|
||||||
|
self.pushButton_exec.clicked.connect(self.exec)
|
||||||
|
self.pushButton_savebuild.clicked.connect(self.build)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -43,7 +45,73 @@ class MyWindow(QWidget,Ui_Form):
|
||||||
field, flag_not, matchexp = cond
|
field, flag_not, matchexp = cond
|
||||||
text += f"字段 {field} 中{'没有' if flag_not else '有 '}{' 或 '.join([t.strip() for t in matchexp.split(',')])}\n"
|
text += f"字段 {field} 中{'没有' if flag_not else '有 '}{' 或 '.join([t.strip() for t in matchexp.split(',')])}\n"
|
||||||
self.label_conditions.setText(text)
|
self.label_conditions.setText(text)
|
||||||
|
def exec(self):
|
||||||
|
self.matchlist = []
|
||||||
|
self.conditions.append(("content",True,"OBSOLETE"))
|
||||||
|
for id in self.pro_dict:
|
||||||
|
if MatchCondition2014(self.pro_dict[id],self.conditions):
|
||||||
|
self.matchlist.append(id)
|
||||||
|
self.conditions = self.conditions[:-1].copy()
|
||||||
|
self.lcdNumber_resCount.display(len(self.matchlist))
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
exp = generate_exp(self.matchlist)
|
||||||
|
SaveTextFile(exp,"临时文件/题号筛选.txt")
|
||||||
|
prodictpath = "../题库0.3/problems.json"
|
||||||
|
objdictpath = "../题库0.3/lessonobj.json"
|
||||||
|
raw_pro_dict = load_dict(prodictpath)
|
||||||
|
configjson = {
|
||||||
|
"pdf标题": "筛选题目编译",
|
||||||
|
"教师版": True,
|
||||||
|
"字段显示设置": {
|
||||||
|
"题后空间": True,
|
||||||
|
"课时目标": True,
|
||||||
|
"题目标签": True,
|
||||||
|
"答案": True,
|
||||||
|
"解答与提示": True,
|
||||||
|
"使用记录": [3,-1],
|
||||||
|
"使用记录说明": "[a,b]表示显示最好的a个和最差b个, 有-2表示不显示, 无-2但有-1表示全部显示",
|
||||||
|
"来源": True,
|
||||||
|
"备注": True,
|
||||||
|
"届别": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grades = configjson["字段显示设置"]["届别"]
|
||||||
|
pro_dict = select_grade_from_pro_dict(raw_pro_dict,grades)
|
||||||
|
obj_dict = load_dict(objdictpath)
|
||||||
|
|
||||||
|
notetitle = configjson["pdf标题"]
|
||||||
|
outputdir = "临时文件" #输出文件的目录
|
||||||
|
outputfilepath = os.path.join(outputdir,notetitle+".tex")
|
||||||
|
print("输出文件目录: %s\n输出文件名: %s"%(os.path.join(os.getcwd(),outputdir),notetitle+".tex"))
|
||||||
|
|
||||||
|
latex_raw = ReadTextFile("模板文件/讲义模板.txt")
|
||||||
|
if configjson["教师版"] == True:
|
||||||
|
latex_raw = latex_raw.replace(r"学号\blank{50} \ 姓名\blank{80}","上海市控江中学")
|
||||||
|
|
||||||
|
if sys.platform != "win32": #非win系统用默认字体
|
||||||
|
latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw)
|
||||||
|
latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw)
|
||||||
|
starttime = time.time()
|
||||||
|
bodystring = "\\begin{enumerate}\n\n"
|
||||||
|
for id in generate_number_set(exp):
|
||||||
|
bodystring += generateLaTeXBodyContent(id,pro_dict,obj_dict,configjson)
|
||||||
|
bodystring += "\\end{enumerate}\n\n"
|
||||||
|
|
||||||
|
midtime = time.time()
|
||||||
|
print(f"生成LaTeX文件所花时间: {midtime-starttime:.3f}秒")
|
||||||
|
|
||||||
|
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,(notetitle,bodystring)) #替换标题和bodystring
|
||||||
|
SaveTextFile(latex_data,outputfilepath) #保存.tex文件
|
||||||
|
|
||||||
|
if XeLaTeXCompile(outputdir,notetitle+".tex"):
|
||||||
|
print("编译成功")
|
||||||
|
else:
|
||||||
|
print("编译失败")
|
||||||
|
|
||||||
|
endtime = time.time()
|
||||||
|
print(f"生成pdf文件所花时间: {endtime-midtime:.3f}秒")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -53,5 +121,3 @@ if __name__ == '__main__':
|
||||||
windows.show()
|
windows.show()
|
||||||
app.exec()
|
app.exec()
|
||||||
|
|
||||||
|
|
||||||
#self.conditions.append(("content",True,"OBSOLETE"))
|
|
||||||
|
|
@ -168,6 +168,11 @@
|
||||||
<height>48</height>
|
<height>48</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>运行</string>
|
<string>运行</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -285,7 +290,7 @@
|
||||||
<widget class="QLCDNumber" name="lcdNumber_resCount">
|
<widget class="QLCDNumber" name="lcdNumber_resCount">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>220</x>
|
<x>120</x>
|
||||||
<y>460</y>
|
<y>460</y>
|
||||||
<width>161</width>
|
<width>161</width>
|
||||||
<height>51</height>
|
<height>51</height>
|
||||||
|
|
@ -298,6 +303,24 @@
|
||||||
<double>0.000000000000000</double>
|
<double>0.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QPushButton" name="pushButton_savebuild">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>300</x>
|
||||||
|
<y>440</y>
|
||||||
|
<width>81</width>
|
||||||
|
<height>71</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>保存和编译</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
||||||
Reference in New Issue