diff --git a/工具v2/Qt面板.py b/工具v2/Qt面板.py index 872eb057..f0d34c09 100644 --- a/工具v2/Qt面板.py +++ b/工具v2/Qt面板.py @@ -40,7 +40,7 @@ class MyWindow(QMainWindow,Ui_MainWindow): self.action_tjjc.triggered.connect(lambda: run_command("添加基础知识梳理",["添加基础知识梳理.py"])) self.action_sxth.triggered.connect(lambda: run_command("关键字筛选题号",[]))#已完成 self.action_xtby.triggered.connect(lambda: run_command("指定题号编译pdf",[]))#已完成 - self.action_sctp.triggered.connect(lambda: run_command("单一题目转成图片文件",["单一题目转成图片文件.py"])) + self.action_sctp.triggered.connect(lambda: run_command("单一题号转为图片",[]))#已完成 self.action_hqth.triggered.connect(lambda: run_command("在.tex或.pdf文件中获取题号",["在.tex或.pdf文件中获取题号.py"])) self.action_jglr.triggered.connect(lambda: run_command("讲义结构编号录入",["讲义结构编号录入.py"])) self.action_dtdy.triggered.connect(lambda: run_command("录入答题纸对应信息",["录入答题纸对应信息.py"])) diff --git a/工具v2/Ui_单一题号转为图片.py b/工具v2/Ui_单一题号转为图片.py new file mode 100644 index 00000000..94386064 --- /dev/null +++ b/工具v2/Ui_单一题号转为图片.py @@ -0,0 +1,57 @@ +# -*- 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, QLineEdit, QPushButton, + QSizePolicy, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(278, 69) + self.label = QLabel(Form) + self.label.setObjectName(u"label") + self.label.setGeometry(QRect(10, 10, 31, 16)) + self.lineEdit_ID = QLineEdit(Form) + self.lineEdit_ID.setObjectName(u"lineEdit_ID") + self.lineEdit_ID.setGeometry(QRect(40, 10, 71, 20)) + self.label_2 = QLabel(Form) + self.label_2.setObjectName(u"label_2") + self.label_2.setGeometry(QRect(10, 40, 31, 16)) + self.lineEdit_dpi = QLineEdit(Form) + self.lineEdit_dpi.setObjectName(u"lineEdit_dpi") + self.lineEdit_dpi.setGeometry(QRect(40, 40, 71, 20)) + self.pushButton_convert = QPushButton(Form) + self.pushButton_convert.setObjectName(u"pushButton_convert") + self.pushButton_convert.setGeometry(QRect(120, 10, 75, 51)) + self.pushButton_open = QPushButton(Form) + self.pushButton_open.setObjectName(u"pushButton_open") + self.pushButton_open.setGeometry(QRect(200, 10, 75, 51)) + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"\u5355\u4e00\u9898\u53f7\u8f6c\u4e3a\u56fe\u7247", None)) + self.label.setText(QCoreApplication.translate("Form", u"\u9898\u53f7", None)) + self.label_2.setText(QCoreApplication.translate("Form", u"DPI", None)) + self.pushButton_convert.setText(QCoreApplication.translate("Form", u"\u8f6c\u6362", None)) + self.pushButton_open.setText(QCoreApplication.translate("Form", u"\u6253\u5f00", None)) + # retranslateUi + diff --git a/工具v2/单一题号转为图片.py b/工具v2/单一题号转为图片.py new file mode 100644 index 00000000..0b213006 --- /dev/null +++ b/工具v2/单一题号转为图片.py @@ -0,0 +1,54 @@ +from PySide6.QtWidgets import QWidget, QApplication, QFileDialog +from Ui_单一题号转为图片 import Ui_Form +from database_tools import * +import os +from datetime import datetime + +class MyWindow(QWidget,Ui_Form): + def __init__(self): + super().__init__() + self.setupUi(self) + self.bind() + + def bind(self): + self.pushButton_open.setDisabled(True) + self.pushButton_convert.clicked.connect(self.convert) + self.pushButton_open.clicked.connect(self.open) + self.lineEdit_ID.textChanged.connect(self.toggleopen) + self.lineEdit_dpi.textChanged.connect(self.toggleopen) + def convert(self): + self.time = datetime.now().strftime("%Y%m%d%H%M%S") + self.id = self.lineEdit_ID.text() + self.dpi = self.lineEdit_dpi.text() + pro_dict = load_dict("../题库0.3/Problems.json") + content = pro_dict[self.id.zfill(6)]["content"] + latex_raw = ReadTextFile("模板文件/独立文件模板.txt") + latexdata = StringSubstitute(r"<<待替换\d*>>",latex_raw,[content]) + makedir("临时文件/pics") + SaveTextFile(latexdata,f"临时文件/pics/ID{self.id}-{self.dpi}-{self.time}.tex") + os.system(f"xelatex -interaction=batchmode -output-directory=临时文件/pics ID{self.id}-{self.dpi}-{self.time}.tex") + os.chdir("临时文件/pics") + os.system(f"pdftocairo -png -r {self.dpi} ID{self.id}-{self.dpi}-{self.time}.pdf") + os.chdir("../..") + self.pushButton_open.setEnabled(True) + def open(self): + os.startfile(os.path.join("临时文件/pics", f"ID{self.id}-{self.dpi}-{self.time}-1.png")) + def toggleopen(self): + self.pushButton_open.setDisabled(True) + + + + + + + + + + + +if __name__ == '__main__': + app = QApplication([]) + windows = MyWindow() + windows.show() + app.exec() + diff --git a/工具v2/单一题号转为图片.ui b/工具v2/单一题号转为图片.ui new file mode 100644 index 00000000..789419b1 --- /dev/null +++ b/工具v2/单一题号转为图片.ui @@ -0,0 +1,91 @@ + + + Form + + + + 0 + 0 + 278 + 69 + + + + 单一题号转为图片 + + + + + 10 + 10 + 31 + 16 + + + + 题号 + + + + + + 40 + 10 + 71 + 20 + + + + + + + 10 + 40 + 31 + 16 + + + + DPI + + + + + + 40 + 40 + 71 + 20 + + + + + + + 120 + 10 + 75 + 51 + + + + 转换 + + + + + + 200 + 10 + 75 + 51 + + + + 打开 + + + + + + diff --git a/工具v2/工具面板.py b/工具v2/工具面板.py index e5675f78..84700708 100644 --- a/工具v2/工具面板.py +++ b/工具v2/工具面板.py @@ -116,7 +116,7 @@ UseMenu.add_command(label = "参考答案生成", command = lambda: SetButton(" UseMenu.add_separator() UseMenu.add_command(label = "文件题号提取", command = lambda: SetButton("文件题号提取",["文件题号提取.py"])) UseMenu.add_separator() -UseMenu.add_command(label = "单一题目转成图片文件", command = lambda: SetButton("单一题目转成图片文件",["单一题目转成图片文件.py"])) +UseMenu.add_command(label = "单一题目转成图片文件", command = lambda: SetButton("单一题号转为图片",[]))