diff --git a/工具v3/Ui_讲义结构与内容录入.py b/工具v3/Ui_讲义结构与内容录入.py new file mode 100644 index 00000000..3cafdf04 --- /dev/null +++ b/工具v3/Ui_讲义结构与内容录入.py @@ -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 + diff --git a/工具v3/讲义结构与内容录入.py b/工具v3/讲义结构与内容录入.py new file mode 100644 index 00000000..167be57a --- /dev/null +++ b/工具v3/讲义结构与内容录入.py @@ -0,0 +1,102 @@ +from PySide6.QtWidgets import QWidget, QApplication, QFileDialog +from Ui_讲义结构与内容录入 import Ui_Form +from database_tools_2 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() + diff --git a/工具v3/讲义结构与内容录入.ui b/工具v3/讲义结构与内容录入.ui new file mode 100644 index 00000000..9400c60d --- /dev/null +++ b/工具v3/讲义结构与内容录入.ui @@ -0,0 +1,158 @@ + + + Form + + + + 0 + 0 + 333 + 41 + + + + Form + + + + + 250 + 10 + 75 + 24 + + + + 执行 + + + + + + 10 + 10 + 221 + 23 + + + + + + + 种类 + + + + + + + + 20 + 16777215 + + + + + + + + 届别 + + + + + + + + 2022 + + + + + 2023 + + + + + 2024 + + + + + 2025 + + + + + 2026 + + + + + 2027 + + + + + 2028 + + + + + 2029 + + + + + + + + 学期 + + + + + + + + 00 + + + + + 01 + + + + + 02 + + + + + 03 + + + + + 04 + + + + + 05 + + + + + 06 + + + + + + + + + +