用Qt重写答题纸对应并加入两个面板

This commit is contained in:
weiye.wang 2024-03-03 20:06:24 +08:00
parent 4c8acfff09
commit d6b7b8a002
5 changed files with 482 additions and 2 deletions

View File

@ -43,7 +43,7 @@ class MyWindow(QMainWindow,Ui_MainWindow):
self.action_sctp.triggered.connect(lambda: run_command("单一题号转为图片",[]))#已完成
self.action_hqth.triggered.connect(lambda: run_command("获取题号",[]))#已完成
self.action_jglr.triggered.connect(lambda: run_command("讲义结构与内容录入",[]))#已完成
self.action_dtdy.triggered.connect(lambda: run_command("录入答题纸对应信息",["录入答题纸对应信息.py"]))
self.action_dtdy.triggered.connect(lambda: run_command("答题纸对应",[]))#已完成
self.action_jysc.triggered.connect(lambda: run_command("系列讲义生成",[]))#已完成
self.action_wbzh.triggered.connect(lambda: run_command("文本转换处理",[]))#已完成

View File

@ -0,0 +1,147 @@
# -*- 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, QComboBox, QHBoxLayout, QLabel,
QLineEdit, QPushButton, QSizePolicy, QWidget)
class Ui_Form(object):
def setupUi(self, Form):
if not Form.objectName():
Form.setObjectName(u"Form")
Form.resize(399, 145)
self.label_2 = QLabel(Form)
self.label_2.setObjectName(u"label_2")
self.label_2.setGeometry(QRect(10, 50, 81, 16))
self.pushButton_exec = QPushButton(Form)
self.pushButton_exec.setObjectName(u"pushButton_exec")
self.pushButton_exec.setEnabled(False)
self.pushButton_exec.setGeometry(QRect(270, 100, 111, 24))
font = QFont()
font.setBold(True)
self.pushButton_exec.setFont(font)
self.widget = QWidget(Form)
self.widget.setObjectName(u"widget")
self.widget.setGeometry(QRect(10, 20, 371, 22))
self.horizontalLayout = QHBoxLayout(self.widget)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.label = QLabel(self.widget)
self.label.setObjectName(u"label")
self.horizontalLayout.addWidget(self.label)
self.lineEdit_xiaoxianid = QLineEdit(self.widget)
self.lineEdit_xiaoxianid.setObjectName(u"lineEdit_xiaoxianid")
self.horizontalLayout.addWidget(self.lineEdit_xiaoxianid)
self.widget1 = QWidget(Form)
self.widget1.setObjectName(u"widget1")
self.widget1.setGeometry(QRect(10, 70, 371, 23))
self.horizontalLayout_2 = QHBoxLayout(self.widget1)
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.label_3 = QLabel(self.widget1)
self.label_3.setObjectName(u"label_3")
self.horizontalLayout_2.addWidget(self.label_3)
self.lineEdit_structure = QLineEdit(self.widget1)
self.lineEdit_structure.setObjectName(u"lineEdit_structure")
self.lineEdit_structure.setMaximumSize(QSize(20, 16777215))
self.horizontalLayout_2.addWidget(self.lineEdit_structure)
self.label_4 = QLabel(self.widget1)
self.label_4.setObjectName(u"label_4")
self.horizontalLayout_2.addWidget(self.label_4)
self.comboBox_grade = QComboBox(self.widget1)
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.setObjectName(u"comboBox_grade")
self.horizontalLayout_2.addWidget(self.comboBox_grade)
self.label_5 = QLabel(self.widget1)
self.label_5.setObjectName(u"label_5")
self.horizontalLayout_2.addWidget(self.label_5)
self.comboBox_semester = QComboBox(self.widget1)
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.setObjectName(u"comboBox_semester")
self.horizontalLayout_2.addWidget(self.comboBox_semester)
self.label_6 = QLabel(self.widget1)
self.label_6.setObjectName(u"label_6")
self.horizontalLayout_2.addWidget(self.label_6)
self.comboBox_index = QComboBox(self.widget1)
self.comboBox_index.setObjectName(u"comboBox_index")
self.horizontalLayout_2.addWidget(self.comboBox_index)
self.retranslateUi(Form)
QMetaObject.connectSlotsByName(Form)
# setupUi
def retranslateUi(self, Form):
Form.setWindowTitle(QCoreApplication.translate("Form", u"\u7b54\u9898\u7eb8\u5bf9\u5e94", None))
self.label_2.setText(QCoreApplication.translate("Form", u"\u5bf9\u5e94\u8bb2\u4e49\u4ee3\u7801", None))
self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u6dfb\u52a0\u7b54\u9898\u7eb8\u5bf9\u5e94", None))
self.label.setText(QCoreApplication.translate("Form", u"\u5c0f\u95f2\u8bd5\u5377ID", None))
self.label_3.setText(QCoreApplication.translate("Form", u"\u7c7b\u578b", None))
self.label_4.setText(QCoreApplication.translate("Form", u"\u5c4a\u522b", None))
self.comboBox_grade.setItemText(0, QCoreApplication.translate("Form", u"2022", None))
self.comboBox_grade.setItemText(1, QCoreApplication.translate("Form", u"2023", None))
self.comboBox_grade.setItemText(2, QCoreApplication.translate("Form", u"2024", None))
self.comboBox_grade.setItemText(3, QCoreApplication.translate("Form", u"2025", None))
self.comboBox_grade.setItemText(4, QCoreApplication.translate("Form", u"2026", None))
self.comboBox_grade.setItemText(5, QCoreApplication.translate("Form", u"2027", None))
self.comboBox_grade.setItemText(6, QCoreApplication.translate("Form", u"2028", None))
self.comboBox_grade.setItemText(7, QCoreApplication.translate("Form", u"2029", None))
self.label_5.setText(QCoreApplication.translate("Form", u"\u5b66\u671f", None))
self.comboBox_semester.setItemText(0, QCoreApplication.translate("Form", u"00", None))
self.comboBox_semester.setItemText(1, QCoreApplication.translate("Form", u"01", None))
self.comboBox_semester.setItemText(2, QCoreApplication.translate("Form", u"02", None))
self.comboBox_semester.setItemText(3, QCoreApplication.translate("Form", u"03", None))
self.comboBox_semester.setItemText(4, QCoreApplication.translate("Form", u"04", None))
self.comboBox_semester.setItemText(5, QCoreApplication.translate("Form", u"05", None))
self.comboBox_semester.setItemText(6, QCoreApplication.translate("Form", u"06", None))
self.label_6.setText(QCoreApplication.translate("Form", u"\u5e8f\u53f7", None))
# retranslateUi

View File

@ -128,7 +128,7 @@ menubar.add_cascade(label = "备课", menu = BKMenu)
# BKMenu.add_command(label = "单课备课稿生成", command = lambda: SetButton("单课备课稿生成",["单课备课稿生成.py"]))
BKMenu.add_command(label = "讲义结构编号录入", command = lambda: SetButton("讲义结构与内容录入",[]))
BKMenu.add_command(label = "在.tex或.pdf文件中获取题号", command = lambda: SetButton("获取题号",[]))
BKMenu.add_command(label = "录入答题纸对应信息", command = lambda: SetButton("录入答题纸对应信息",["录入答题纸对应信息.py"]))
BKMenu.add_command(label = "录入答题纸对应信息", command = lambda: SetButton("答题纸对应",[]))
BKMenu.add_command(label = "讲义生成", command = lambda: SetButton("讲义生成",["讲义生成.py"]))
BKMenu.add_command(label = "系列讲义生成", command = lambda: SetButton("系列讲义生成",[]))
BKMenu.add_separator()

122
工具v2/答题纸对应.py Normal file
View File

@ -0,0 +1,122 @@
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
from Ui_答题纸对应 import Ui_Form
from database_tools import *
def getindices(string):
indices_list = []
notesjsonpath = f"../备课组/{string[3:5]}届/校本材料.json"
try:
notesjson = load_dict(notesjsonpath)
for id in notesjson["notes"]:
if id.startswith(string):
indices_list.append(id[-2:])
return indices_list
except:
return []
class MyWindow(QWidget,Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.bind()
def bind(self):
self.comboBox_grade.activated.connect(self.setindex)
self.comboBox_semester.activated.connect(self.setindex)
self.lineEdit_structure.textChanged.connect(self.setindex)
self.comboBox_index.activated.connect(self.activateexec)
self.pushButton_exec.clicked.connect(self.exec)
def setindex(self):
self.comboBox_index.clear()
self.structure = self.lineEdit_structure.text().upper()
self.grade = self.comboBox_grade.currentText()
self.semester = self.comboBox_semester.currentText()
self.initialstring = f"{self.structure}{self.grade}{self.semester}"
self.indices = getindices(self.initialstring)
self.comboBox_index.addItems(self.indices)
if self.indices == []:
self.pushButton_exec.setDisabled(True)
else:
self.pushButton_exec.setEnabled(True)
def activateexec(self):
self.pushButton_exec.setEnabled(True)
def exec(self):
pid = f"{self.structure}{self.grade}{self.semester}{self.comboBox_index.currentText()}"
answersheetjson = f"../备课组/{self.grade[-2:]}届/答题纸对应.json"
notesjson = f"../备课组/{self.grade[-2:]}届/校本材料.json"
answersheet_dict = load_dict(answersheetjson)
notes_dict = load_dict(notesjson)
new_dict = {}
if not pid in notes_dict["notes"]:
print("讲义编号有误.")
else:
new_dict["id"] = pid
corresponding_method = input("用何种方式对应? 题号(I)/章节标题(P):")
if corresponding_method[0].upper() == "I":
new_dict["idlist"] = []
count = 1
id = input(f"输入第 {count} 题的题号(S表示跳过, E表示结束):")
while len(re.findall(r"[Ss\d,:]",id)) == len(id):
if "S" in id.upper():
new_dict["idlist"].append("999999")
count += 1
else:
new_id_list = generate_number_set(id)
new_dict["idlist"] += [i.zfill(6) for i in new_id_list]
count += len(new_id_list)
id = input(f"输入第 {count} 题的题号(S表示跳过, E表示结束):")
elif corresponding_method[0].upper() == "P":
structure = notes_dict["structures"][pid[0]]["structure"]
count = 1
partslist = []
for key in structure:
print(f"{count}. {key}: {structure[key]['name']}")
count += 1
partslist.append(key)
parts_selected_string = input("使用哪些部分(输入数字编号, 用';'分隔):")
parts_selected_index = parts_selected_string.strip().split(";")
parts_selected = []
for i in parts_selected_index:
parts_selected.append(partslist[int(i)-1])
new_dict["parts"] = parts_selected.copy()
marksflag = input("是否为每个结果赋分(Y/N):")
if marksflag[0].upper() == "Y":
new_dict["marks"] = []
count = 1
mark = input(f"依次输入分数, 非自然数作为结束(第 {count} 个位置):")
while len(re.findall(r"\d",mark)) == len(mark):
new_dict["marks"].append(int(mark))
count += 1
mark = input(f"依次输入分数, 非自然数作为结束(第 {count} 个位置):")
answersheet_dict[self.lineEdit_xiaoxianid.text()] = new_dict.copy()
save_dict(answersheet_dict,answersheetjson)
print("设置完成")
if __name__ == '__main__':
app = QApplication([])
windows = MyWindow()
windows.show()
app.exec()

211
工具v2/答题纸对应.ui Normal file
View File

@ -0,0 +1,211 @@
<?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>399</width>
<height>145</height>
</rect>
</property>
<property name="windowTitle">
<string>答题纸对应</string>
</property>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>对应讲义代码</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_exec">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>270</x>
<y>100</y>
<width>111</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>添加答题纸对应</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>371</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>小闲试卷ID</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_xiaoxianid"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>371</width>
<height>23</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>类型</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_structure">
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>届别</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_grade">
<item>
<property name="text">
<string>2022</string>
</property>
</item>
<item>
<property name="text">
<string>2023</string>
</property>
</item>
<item>
<property name="text">
<string>2024</string>
</property>
</item>
<item>
<property name="text">
<string>2025</string>
</property>
</item>
<item>
<property name="text">
<string>2026</string>
</property>
</item>
<item>
<property name="text">
<string>2027</string>
</property>
</item>
<item>
<property name="text">
<string>2028</string>
</property>
</item>
<item>
<property name="text">
<string>2029</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>学期</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_semester">
<item>
<property name="text">
<string>00</string>
</property>
</item>
<item>
<property name="text">
<string>01</string>
</property>
</item>
<item>
<property name="text">
<string>02</string>
</property>
</item>
<item>
<property name="text">
<string>03</string>
</property>
</item>
<item>
<property name="text">
<string>04</string>
</property>
</item>
<item>
<property name="text">
<string>05</string>
</property>
</item>
<item>
<property name="text">
<string>06</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>序号</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_index"/>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>