用Qt重写 讲义结构与内容录入 并加入两个面板

This commit is contained in:
weiye.wang 2024-03-03 18:06:31 +08:00
parent c21a75fb3f
commit 4c8acfff09
5 changed files with 373 additions and 2 deletions

View File

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

View File

@ -0,0 +1,111 @@
# -*- 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(333, 41)
self.pushButton_exec = QPushButton(Form)
self.pushButton_exec.setObjectName(u"pushButton_exec")
self.pushButton_exec.setGeometry(QRect(250, 10, 75, 24))
self.widget = QWidget(Form)
self.widget.setObjectName(u"widget")
self.widget.setGeometry(QRect(10, 10, 221, 23))
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_structure = QLineEdit(self.widget)
self.lineEdit_structure.setObjectName(u"lineEdit_structure")
self.lineEdit_structure.setMaximumSize(QSize(20, 16777215))
self.horizontalLayout.addWidget(self.lineEdit_structure)
self.label_2 = QLabel(self.widget)
self.label_2.setObjectName(u"label_2")
self.horizontalLayout.addWidget(self.label_2)
self.comboBox_grade = QComboBox(self.widget)
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.addWidget(self.comboBox_grade)
self.label_3 = QLabel(self.widget)
self.label_3.setObjectName(u"label_3")
self.horizontalLayout.addWidget(self.label_3)
self.comboBox_semester = QComboBox(self.widget)
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.addWidget(self.comboBox_semester)
self.retranslateUi(Form)
QMetaObject.connectSlotsByName(Form)
# setupUi
def retranslateUi(self, Form):
Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u6267\u884c", None))
self.label.setText(QCoreApplication.translate("Form", u"\u79cd\u7c7b", None))
self.label_2.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_3.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))
# retranslateUi

View File

@ -126,7 +126,7 @@ menubar.add_cascade(label = "备课", menu = BKMenu)
# BKMenu.add_command(label = "新课备课所用题目草稿生成", command = lambda: SetButton("新课备课所用题目草稿生成",["新课备课所用题目草稿生成.py"]))
# BKMenu.add_command(label = "新课备课稿合集生成", command = lambda: SetButton("新课备课稿合集生成",["新课备课稿合集生成.py"]))
# BKMenu.add_command(label = "单课备课稿生成", command = lambda: SetButton("单课备课稿生成",["单课备课稿生成.py"]))
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("讲义生成",["讲义生成.py"]))

View File

@ -0,0 +1,102 @@
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
from Ui_讲义结构与内容录入 import Ui_Form
from database_tools import *
class MyWindow(QWidget,Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.bind()
def bind(self):
self.pushButton_exec.clicked.connect(self.exec)
def exec(self):
if not len(self.lineEdit_structure.text()) == 1:
pass
print("首字母有误")
else:
self.prefix = self.lineEdit_structure.text().upper()+self.comboBox_grade.currentText()+self.comboBox_semester.currentText()
jsonfile = f"../备课组/{self.prefix[3:5]}届/校本材料.json"
notes_dict = load_dict(jsonfile)
# print(len(notes_dict))
if not self.prefix[0] in notes_dict["structures"]:
AddNew = input("此类型不在列表中, 新增(A)/退出(Q):")
if AddNew[0].upper() == "A":
descr = input("类型描述:")
cn = input("编号是否连续(T/F):")
if cn[0].upper() == "T":
cn = True
else:
cn = False
partscount = int(input("分为多少个部分:"))
new_struct_dict = {
"description": descr,
"consecutivenumbering": cn,
"structure": {}
}
for i in range(partscount):
partid = input(f"{i+1} 部分的代号:")
partname = input(f"部分 {partid} 的名称:")
spaceflag = input(f"部分 {partid}: {partname} 中是否要在题目后留空格(T/F):")
if spaceflag[0].upper() == "T":
spaceflag = True
else:
spaceflag = False
new_struct_dict["structure"][partid] = {
"name": partname,
"spaceflag": spaceflag
}
notes_dict["structures"][self.prefix[0]] = new_struct_dict.copy()
save_dict(notes_dict,jsonfile)
else:
pass
else:
numberlist = []
for id in notes_dict["notes"]:
if self.prefix in id:
numberlist.append(id[-2:])
print("该分类下已有材料编号: "+generate_exp(numberlist))
pid = self.prefix + input("请输入新材料编号(两位数):")
while pid in notes_dict["notes"]:
print("编号重复, 请重新输入.")
pid = self.prefix + input("请输入新材料编号(两位数):")
name = input("请输入材料名称:")
filenameraw = input("生成的文件名和材料名称是否一致?([Y]/如果不一致请输入文件名):")
if filenameraw.upper() == "Y":
filename = name
else:
filename = filenameraw
new_note_dict = {
"id": pid,
"name": name,
"filename": filename
}
structure = notes_dict['structures'][self.prefix[0]]['structure']
print(f"此类材料共有 {len(structure)} 个部分, 分别是:")
for p in structure:
print(f"{p}: {structure[p]['name']}")
new_note_dict[p] = []
for p in structure:
rawdata = input(f"现在输入 {p}: {structure[p]['name']} 部分的内容编号:")
rawdata = re.sub(r"[^BXK\d:,]","",rawdata)
if re.findall(r"\d",rawdata) == []:
new_note_dict[p] = []
else:
new_note_dict[p] = generate_id_set(rawdata)
print(f"{p}: {new_note_dict[p]}")
notes_dict["notes"][pid] = new_note_dict.copy()
notes_dict["notes"] = SortDict(notes_dict["notes"])
save_dict(notes_dict,jsonfile)
print("处理完成")
if __name__ == '__main__':
app = QApplication([])
windows = MyWindow()
windows.show()
app.exec()

View File

@ -0,0 +1,158 @@
<?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>333</width>
<height>41</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="pushButton_exec">
<property name="geometry">
<rect>
<x>250</x>
<y>10</y>
<width>75</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>执行</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>221</width>
<height>23</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<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_2">
<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_3">
<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>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>