diff --git a/工具v4/Ui_tool_panel.py b/工具v4/Ui_tool_panel.py
index 59779f61..51ca0290 100644
--- a/工具v4/Ui_tool_panel.py
+++ b/工具v4/Ui_tool_panel.py
@@ -150,15 +150,15 @@ class Ui_MainWindow(object):
self.horizontalLayout = QHBoxLayout(self.horizontalLayoutWidget)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
- self.pushButton = QPushButton(self.horizontalLayoutWidget)
- self.pushButton.setObjectName(u"pushButton")
+ self.pushButton_tiku = QPushButton(self.horizontalLayoutWidget)
+ self.pushButton_tiku.setObjectName(u"pushButton_tiku")
- self.horizontalLayout.addWidget(self.pushButton)
+ self.horizontalLayout.addWidget(self.pushButton_tiku)
- self.pushButton_2 = QPushButton(self.horizontalLayoutWidget)
- self.pushButton_2.setObjectName(u"pushButton_2")
+ self.pushButton_tikutest = QPushButton(self.horizontalLayoutWidget)
+ self.pushButton_tikutest.setObjectName(u"pushButton_tikutest")
- self.horizontalLayout.addWidget(self.pushButton_2)
+ self.horizontalLayout.addWidget(self.pushButton_tikutest)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
@@ -171,11 +171,11 @@ class Ui_MainWindow(object):
self.retranslateUi(MainWindow)
- self.tabWidget_main.setCurrentIndex(4)
+ self.tabWidget_main.setCurrentIndex(3)
self.tabWidget_luru.setCurrentIndex(2)
self.tabWidget_weihu.setCurrentIndex(5)
self.tabWidget_shiyong.setCurrentIndex(4)
- self.tabWidget_beikezu.setCurrentIndex(2)
+ self.tabWidget_beikezu.setCurrentIndex(1)
self.tabWidget.setCurrentIndex(1)
@@ -212,7 +212,7 @@ class Ui_MainWindow(object):
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_wbzh), QCoreApplication.translate("MainWindow", u"\u6587\u672c\u8f6c\u6362\u5904\u7406", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_hist), QCoreApplication.translate("MainWindow", u"\u76f4\u65b9\u56fe\u4ee3\u7801\u751f\u6210", None))
self.tabWidget_main.setTabText(self.tabWidget_main.indexOf(self.tab_latex), QCoreApplication.translate("MainWindow", u"LaTeX\u4ee3\u7801\u76f8\u5173", None))
- self.pushButton.setText(QCoreApplication.translate("MainWindow", u"\u6b63\u5f0f\u6570\u636e\u5e93", None))
- self.pushButton_2.setText(QCoreApplication.translate("MainWindow", u"\u6d4b\u8bd5\u6570\u636e\u5e93", None))
+ self.pushButton_tiku.setText(QCoreApplication.translate("MainWindow", u"\u6b63\u5f0f\u6570\u636e\u5e93", None))
+ self.pushButton_tikutest.setText(QCoreApplication.translate("MainWindow", u"\u6d4b\u8bd5\u6570\u636e\u5e93", None))
# retranslateUi
diff --git a/工具v4/Ui_寻找空闲题号.py b/工具v4/Ui_寻找空闲题号.py
new file mode 100644
index 00000000..34f45c0f
--- /dev/null
+++ b/工具v4/Ui_寻找空闲题号.py
@@ -0,0 +1,63 @@
+# -*- 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, QFrame, QLabel, QPushButton,
+ QSizePolicy, QWidget)
+
+class Ui_Form(object):
+ def setupUi(self, Form):
+ if not Form.objectName():
+ Form.setObjectName(u"Form")
+ Form.resize(800, 490)
+ self.label_used = QLabel(Form)
+ self.label_used.setObjectName(u"label_used")
+ self.label_used.setGeometry(QRect(20, 50, 291, 401))
+ self.label_used.setFrameShape(QFrame.StyledPanel)
+ self.label_used.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
+ self.label_available = QLabel(Form)
+ self.label_available.setObjectName(u"label_available")
+ self.label_available.setGeometry(QRect(330, 50, 291, 401))
+ self.label_available.setFrameShape(QFrame.StyledPanel)
+ self.label_available.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
+ self.label = QLabel(Form)
+ self.label.setObjectName(u"label")
+ self.label.setGeometry(QRect(30, 20, 71, 16))
+ self.label_2 = QLabel(Form)
+ self.label_2.setObjectName(u"label_2")
+ self.label_2.setGeometry(QRect(340, 20, 71, 16))
+ self.pushButton_exec = QPushButton(Form)
+ self.pushButton_exec.setObjectName(u"pushButton_exec")
+ self.pushButton_exec.setGeometry(QRect(640, 50, 141, 401))
+ 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"\u5bfb\u627e\u7a7a\u95f2\u9898\u53f7", None))
+ self.label_used.setText(QCoreApplication.translate("Form", u"TextLabel", None))
+ self.label_available.setText(QCoreApplication.translate("Form", u"TextLabel", None))
+ self.label.setText(QCoreApplication.translate("Form", u"\u5df2\u4f7f\u7528\u9898\u53f7", None))
+ self.label_2.setText(QCoreApplication.translate("Form", u"\u7a7a\u95f2\u9898\u53f7", None))
+ self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u751f\u6210\u5df2\u4f7f\u7528\u9898\u53f7\u5217\u8868\n"
+"\u53ca\u7a7a\u95f2\u9898\u53f7\u5217\u8868", None))
+ # retranslateUi
+
diff --git a/工具v4/database_tools_2.py b/工具v4/database_tools_2.py
index e130b44e..1dde7125 100644
--- a/工具v4/database_tools_2.py
+++ b/工具v4/database_tools_2.py
@@ -350,8 +350,25 @@ def extractIDs(filePath): #提取.txt,.tex或.pdf文件中的题号, 返回含
return generate_exp(ids)
-def spareIDs(): #返回空闲题号, 已更新为适合mariadb的版本
- mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = db_database)
+def usedIDs(database_name): #返回已使用题号, 已更新为适合mariadb的版本
+ mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = database_name)
+ mycursor = mydb.cursor()
+ mycursor.execute("SELECT ID FROM problems;")
+ idlist = [ret[0] for ret in mycursor.fetchall()]
+ used_str = generate_exp(idlist)
+ used_list = used_str.split(",")
+ output = ""
+ for group in used_list:
+ interval = group.split(":")
+ start = interval[0]
+ end = interval[-1]
+ output += "首个已使用id: %s, 直至: %s"%(str(start).zfill(6),str(end).zfill(6)) + "\n"
+ output = output.strip()
+ mydb.close()
+ return output #返回的是一个多行的字符串, 每一行中含有一个已使用题号的闭区间
+
+def spareIDs(database_name): #返回空闲题号, 已更新为适合mariadb的版本
+ mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = database_name)
mycursor = mydb.cursor()
mycursor.execute("SELECT ID FROM problems;")
idlist = [ret[0] for ret in mycursor.fetchall()]
diff --git a/工具v4/tool_panel.py b/工具v4/tool_panel.py
index d7c3a066..18797a26 100644
--- a/工具v4/tool_panel.py
+++ b/工具v4/tool_panel.py
@@ -1,11 +1,30 @@
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog, QMainWindow
from Ui_tool_panel import Ui_MainWindow
+from 寻找空闲题号 import MyWindow_kxth
from database_tools_2 import *
class MyWindow(QMainWindow,Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
+ self.bind()
+ def bind(self):
+ self.SelectTIKUTEST()
+ self.pushButton_tiku.clicked.connect(self.SelectTIKU)
+ self.pushButton_tikutest.clicked.connect(self.SelectTIKUTEST) #以上为设置当前数据库的两个按钮
+ tab_kxth = MyWindow_kxth(self.database) #传递参数时有问题, 未能动态更新
+ for i in range(3):
+ self.tabWidget_luru.removeTab(0)
+ self.tabWidget_luru.addTab(tab_kxth,"寻找空闲题号")
+ def SelectTIKU(self):
+ self.pushButton_tiku.setStyleSheet("background-color: green; font-weight: bold;") #绿色背景粗体
+ self.pushButton_tikutest.setStyleSheet("") #恢复原有背景, 取消粗体
+ self.database = "tiku"
+ def SelectTIKUTEST(self):
+ self.pushButton_tikutest.setStyleSheet("background-color: green; font-weight: bold;") #绿色背景粗体
+ self.pushButton_tiku.setStyleSheet("") #恢复原有背景, 取消粗体
+ self.database = "tikutest"
+
diff --git a/工具v4/tool_panel.ui b/工具v4/tool_panel.ui
index 6fae0b3d..af36c9ec 100644
--- a/工具v4/tool_panel.ui
+++ b/工具v4/tool_panel.ui
@@ -27,7 +27,7 @@
QTabWidget::Triangular
- 4
+ 3
@@ -217,7 +217,7 @@
QTabWidget::Triangular
- 2
+ 1
@@ -282,14 +282,14 @@
-
-
+
正式数据库
-
-
+
测试数据库
diff --git a/工具v4/寻找空闲题号.py b/工具v4/寻找空闲题号.py
new file mode 100644
index 00000000..6b9d272b
--- /dev/null
+++ b/工具v4/寻找空闲题号.py
@@ -0,0 +1,33 @@
+from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
+from Ui_寻找空闲题号 import Ui_Form
+from database_tools_2 import *
+
+
+class MyWindow_kxth(QWidget,Ui_Form):
+ def __init__(self,database_name):
+ super().__init__()
+ self.databaes_name = database_name
+ self.setupUi(self)
+ self.bind()
+ def bind(self):
+ self.label_used.setText("")
+ self.label_available.setText("")
+ self.pushButton_exec.clicked.connect(self.exec)
+
+
+ def exec(self):
+ self.label_used.setText(usedIDs(self.databaes_name))
+ self.label_available.setText(spareIDs(self.databaes_name))
+ print(self.databaes_name)
+
+
+
+
+
+
+if __name__ == '__main__':
+ app = QApplication([])
+ windows = MyWindow()
+ windows.show()
+ app.exec()
+
diff --git a/工具v4/寻找空闲题号.ui b/工具v4/寻找空闲题号.ui
new file mode 100644
index 00000000..fca71086
--- /dev/null
+++ b/工具v4/寻找空闲题号.ui
@@ -0,0 +1,102 @@
+
+
+ Form
+
+
+
+ 0
+ 0
+ 800
+ 490
+
+
+
+ 寻找空闲题号
+
+
+
+
+ 20
+ 50
+ 291
+ 401
+
+
+
+ QFrame::StyledPanel
+
+
+ TextLabel
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
+
+
+
+
+ 330
+ 50
+ 291
+ 401
+
+
+
+ QFrame::StyledPanel
+
+
+ TextLabel
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
+
+
+
+
+ 30
+ 20
+ 71
+ 16
+
+
+
+ 已使用题号
+
+
+
+
+
+ 340
+ 20
+ 71
+ 16
+
+
+
+ 空闲题号
+
+
+
+
+
+ 640
+ 50
+ 141
+ 401
+
+
+
+
+ true
+
+
+
+ 生成已使用题号列表
+及空闲题号列表
+
+
+
+
+
+