From a362b5145199555e1c2a3b5f9f0adc927d7c6638 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Thu, 25 Apr 2024 23:08:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=20=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=BB=93=E6=9E=9C=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v4/Ui_手动统计结果导入.py | 58 +++++++++++++++++++++++++++ 工具v4/tool_panel.py | 7 +++- 工具v4/手动统计结果导入.py | 46 +++++++++++++++++++++ 工具v4/手动统计结果导入.ui | 75 +++++++++++++++++++++++++++++++++++ 4 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 工具v4/Ui_手动统计结果导入.py create mode 100644 工具v4/手动统计结果导入.py create mode 100644 工具v4/手动统计结果导入.ui diff --git a/工具v4/Ui_手动统计结果导入.py b/工具v4/Ui_手动统计结果导入.py new file mode 100644 index 00000000..df678792 --- /dev/null +++ b/工具v4/Ui_手动统计结果导入.py @@ -0,0 +1,58 @@ +# -*- 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, QLabel, QPlainTextEdit, QPushButton, + QSizePolicy, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(760, 490) + self.plainTextEdit = QPlainTextEdit(Form) + self.plainTextEdit.setObjectName(u"plainTextEdit") + self.plainTextEdit.setEnabled(True) + self.plainTextEdit.setGeometry(QRect(250, 150, 181, 141)) + self.plainTextEdit.setReadOnly(True) + self.label = QLabel(Form) + self.label.setObjectName(u"label") + self.label.setGeometry(QRect(250, 130, 101, 16)) + self.pushButton_exec = QPushButton(Form) + self.pushButton_exec.setObjectName(u"pushButton_exec") + self.pushButton_exec.setGeometry(QRect(440, 130, 75, 161)) + font = QFont() + font.setBold(True) + self.pushButton_exec.setFont(font) + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"\u624b\u52a8\u7edf\u8ba1\u7ed3\u679c\u5bfc\u5165", None)) + self.plainTextEdit.setPlainText(QCoreApplication.translate("Form", u"[BEGIN]\n" +"##20240101\n" +"**2026\u5c4a\u9ad8\u4e0001\u73ed\n" +"1 0.875\n" +"10001 0.825 0.630\n" +"[END]", None)) + self.label.setText(QCoreApplication.translate("Form", u"\u624b\u52a8\u7edf\u8ba1\u7ed3\u679c\u6a21\u677f", None)) + self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u5bfc\u5165\u4e3a\n" +"metadata", None)) + # retranslateUi + diff --git a/工具v4/tool_panel.py b/工具v4/tool_panel.py index 5fbbfa60..b0e8c26b 100644 --- a/工具v4/tool_panel.py +++ b/工具v4/tool_panel.py @@ -20,6 +20,7 @@ from 共享使用记录 import MyWindow_gxsy from 文件或文本框提取答案 import MyWindow_tqda from 单元挂钩 import MyWindow_dygg from 统考数据导入 import MyWindow_tkdr +from 手动统计结果导入 import MyWindow_sddr from database_tools_2 import * class MyWindow(QMainWindow,Ui_MainWindow): @@ -48,9 +49,13 @@ class MyWindow(QMainWindow,Ui_MainWindow): self.layout_tjgl.addWidget(self.tjgl) #以上三行为初始化“添加关联”tab + self.layout_sddr = QVBoxLayout(self.tab_sddr) + self.sddr = MyWindow_sddr() + self.layout_sddr.addWidget(self.sddr) #以上三行为初始化“手动统计数据导入”tab + self.layout_tkdr = QVBoxLayout(self.tab_tkdr) self.tkdr = MyWindow_tkdr() - self.layout_tkdr.addWidget(self.tkdr) #以上三行为初始化“提取答案”tab + self.layout_tkdr.addWidget(self.tkdr) #以上三行为初始化“统考数据导入”tab self.layout_dygg = QVBoxLayout(self.tab_dygg) self.dygg = MyWindow_dygg(self.database) diff --git a/工具v4/手动统计结果导入.py b/工具v4/手动统计结果导入.py new file mode 100644 index 00000000..d3716a36 --- /dev/null +++ b/工具v4/手动统计结果导入.py @@ -0,0 +1,46 @@ +from PySide6.QtWidgets import QWidget, QApplication, QFileDialog +from Ui_手动统计结果导入 import Ui_Form +from database_tools_2 import * + +class MyWindow_sddr(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): + handmadeusagedatafilepath = r"临时文件/手动统计结果.txt" #手动统计文件的位置 + metadatafilepath = r"文本文件/metadata.txt" #输出的metadata文件的位置 + raw_data = ReadTextFile(handmadeusagedatafilepath) + data_list = [d.strip() for d in re.findall(r"\[BEGIN\]([\s\S]*?)\[END\]",raw_data)] + output = "usages\n\n" + for item in data_list: + lines = item.split("\n") + for line in lines: + if line.startswith("##"): + date = line.replace("##","").strip() + elif line.startswith("**"): + classname = line.replace("**","").strip() + else: + linedata = re.sub(r"\s+","\t",line) + usage = linedata.split("\t") + id = usage.pop(0) + usagestr = "\t".join([f"{float(u):.3f}" for u in usage]) + output += "%s\n%s\t%s\t%s\n\n"%(id.zfill(6),date,classname,usagestr) + SaveTextFile(output,metadatafilepath) + os.system(f"code {metadatafilepath}") + self.close() + + + + + + + +if __name__ == '__main__': + app = QApplication([]) + windows = MyWindow_sddr() + windows.show() + app.exec() + diff --git a/工具v4/手动统计结果导入.ui b/工具v4/手动统计结果导入.ui new file mode 100644 index 00000000..41b4e927 --- /dev/null +++ b/工具v4/手动统计结果导入.ui @@ -0,0 +1,75 @@ + + + Form + + + + 0 + 0 + 760 + 490 + + + + 手动统计结果导入 + + + + true + + + + 250 + 150 + 181 + 141 + + + + true + + + [BEGIN] +##20240101 +**2026届高一01班 +1 0.875 +10001 0.825 0.630 +[END] + + + + + + 250 + 130 + 101 + 16 + + + + 手动统计结果模板 + + + + + + 440 + 130 + 75 + 161 + + + + + true + + + + 导入为 +metadata + + + + + +