迁移 讲义结构与内容录入

This commit is contained in:
weiye.wang 2024-04-25 19:14:29 +08:00
parent 34e410d71b
commit d539f4c897
4 changed files with 403 additions and 1 deletions

View File

@ -0,0 +1,115 @@
# -*- 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(760, 490)
self.pushButton_exec = QPushButton(Form)
self.pushButton_exec.setObjectName(u"pushButton_exec")
self.pushButton_exec.setGeometry(QRect(460, 200, 75, 24))
self.layoutWidget = QWidget(Form)
self.layoutWidget.setObjectName(u"layoutWidget")
self.layoutWidget.setGeometry(QRect(220, 200, 221, 23))
self.horizontalLayout = QHBoxLayout(self.layoutWidget)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.label = QLabel(self.layoutWidget)
self.label.setObjectName(u"label")
self.horizontalLayout.addWidget(self.label)
self.lineEdit_structure = QLineEdit(self.layoutWidget)
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.layoutWidget)
self.label_2.setObjectName(u"label_2")
self.horizontalLayout.addWidget(self.label_2)
self.comboBox_grade = QComboBox(self.layoutWidget)
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.layoutWidget)
self.label_3.setObjectName(u"label_3")
self.horizontalLayout.addWidget(self.label_3)
self.comboBox_semester = QComboBox(self.layoutWidget)
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.label_next = QLabel(Form)
self.label_next.setObjectName(u"label_next")
self.label_next.setGeometry(QRect(400, 240, 141, 16))
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))
self.label_next.setText(QCoreApplication.translate("Form", u"\u8bf7\u5230\u7ec8\u7aef\u6267\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c", None))
# retranslateUi

View File

@ -5,6 +5,7 @@ from 寻找空闲题号 import MyWindow_kxth
from 生成直方图代码 import MyWindow_hist
from 文本转换处理 import MyWindow_wbzh
from 系列讲义生成 import MyWindow_jysc
from 讲义结构与内容录入 import MyWindow_jglr
from database_tools_2 import *
class MyWindow(QMainWindow,Ui_MainWindow):
@ -24,9 +25,13 @@ class MyWindow(QMainWindow,Ui_MainWindow):
self.kxth = MyWindow_kxth(self.database)
self.layout_kxth.addWidget(self.kxth) #以上三行为初始化“空闲题号”tab
self.layout_jglr = QVBoxLayout(self.tab_jglr)
self.jglr = MyWindow_jglr()
self.layout_jglr.addWidget(self.jglr) #以上三行为初始化“空闲题号”tab
self.layout_jysc = QVBoxLayout(self.tab_jysc)
self.jysc = MyWindow_jysc()
self.jysc = MyWindow_jysc(self.database)
self.layout_jysc.addWidget(self.jysc) #以上三行为初始化“LaTeX代码转换”tab
self.layout_wbzh = QVBoxLayout(self.tab_wbzh)

View File

@ -0,0 +1,111 @@
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
from Ui_讲义结构与内容录入 import Ui_Form
from database_tools_2 import *
class MyWindow_jglr(QWidget,Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.bind()
def bind(self):
self.label_next.setVisible(False)
self.pushButton_exec.clicked.connect(self.exec)
self.lineEdit_structure.textChanged.connect(self.unvisible)
self.comboBox_grade.currentIndexChanged.connect(self.unvisible)
self.comboBox_semester.currentIndexChanged.connect(self.unvisible)
def unvisible(self):
self.label_next.setVisible(False)
def exec(self):
if not len(self.lineEdit_structure.text()) == 1:
print("首字母有误")
else:
self.label_next.setVisible(True)
self.repaint()
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,171 @@
<?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>760</width>
<height>490</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="pushButton_exec">
<property name="geometry">
<rect>
<x>460</x>
<y>200</y>
<width>75</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>执行</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>220</x>
<y>200</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 class="QLabel" name="label_next">
<property name="geometry">
<rect>
<x>400</x>
<y>240</y>
<width>141</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>请到终端执行下一步操作</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>