寻找空闲题号功能新做了Qt面板
This commit is contained in:
parent
a0890e5adf
commit
2fec406212
|
|
@ -0,0 +1,48 @@
|
||||||
|
# -*- 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, QLineEdit,
|
||||||
|
QPushButton, QSizePolicy, QWidget)
|
||||||
|
|
||||||
|
class Ui_Form(object):
|
||||||
|
def setupUi(self, Form):
|
||||||
|
if not Form.objectName():
|
||||||
|
Form.setObjectName(u"Form")
|
||||||
|
Form.resize(400, 300)
|
||||||
|
self.pushButton_SelectFilepath = QPushButton(Form)
|
||||||
|
self.pushButton_SelectFilepath.setObjectName(u"pushButton_SelectFilepath")
|
||||||
|
self.pushButton_SelectFilepath.setGeometry(QRect(20, 20, 75, 24))
|
||||||
|
self.lineEdit_FilePath = QLineEdit(Form)
|
||||||
|
self.lineEdit_FilePath.setObjectName(u"lineEdit_FilePath")
|
||||||
|
self.lineEdit_FilePath.setGeometry(QRect(20, 50, 361, 20))
|
||||||
|
self.label_Available = QLabel(Form)
|
||||||
|
self.label_Available.setObjectName(u"label_Available")
|
||||||
|
self.label_Available.setGeometry(QRect(20, 80, 361, 201))
|
||||||
|
self.label_Available.setFrameShape(QFrame.StyledPanel)
|
||||||
|
self.label_Available.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
|
||||||
|
|
||||||
|
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.pushButton_SelectFilepath.setText(QCoreApplication.translate("Form", u"\u9009\u62e9\u6587\u4ef6", None))
|
||||||
|
self.label_Available.setText(QCoreApplication.translate("Form", u"TextLabel", None))
|
||||||
|
# retranslateUi
|
||||||
|
|
||||||
|
|
@ -1,5 +1,37 @@
|
||||||
|
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
|
||||||
|
from Ui_寻找空闲题号 import Ui_Form
|
||||||
from database_tools import *
|
from database_tools import *
|
||||||
|
|
||||||
pro_dict = load_dict(r"..\题库0.3\Problems.json")
|
|
||||||
print(spareIDs(pro_dict))
|
class MyWindow(QWidget,Ui_Form):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.setupUi(self)
|
||||||
|
self.bind()
|
||||||
|
self.lineEdit_FilePath.setText(os.path.join(os.path.dirname(os.getcwd()),"题库0.3","Problems.json"))
|
||||||
|
self.ShowAvailable()
|
||||||
|
|
||||||
|
|
||||||
|
def bind(self):
|
||||||
|
self.pushButton_SelectFilepath.clicked.connect(self.getFilePathandShow)
|
||||||
|
|
||||||
|
def ShowAvailable(self):
|
||||||
|
self.jsonpath = self.lineEdit_FilePath.text()
|
||||||
|
pro_dict = load_dict(self.jsonpath)
|
||||||
|
self.label_Available.setText(spareIDs(pro_dict))
|
||||||
|
|
||||||
|
def getFilePathandShow(self):
|
||||||
|
pathlist = QFileDialog.getOpenFileName(self,"选择文件",".","json文件(*.json);;所有文件(*)")
|
||||||
|
self.lineEdit_FilePath.setText(pathlist[0])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app = QApplication([])
|
||||||
|
windows = MyWindow()
|
||||||
|
windows.show()
|
||||||
|
app.exec()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?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>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>寻找空闲题号</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QPushButton" name="pushButton_SelectFilepath">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>75</width>
|
||||||
|
<height>24</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>选择文件</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_FilePath">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>50</y>
|
||||||
|
<width>361</width>
|
||||||
|
<height>20</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label_Available">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>80</y>
|
||||||
|
<width>361</width>
|
||||||
|
<height>201</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
from database_tools import *
|
||||||
|
|
||||||
|
pro_dict = load_dict(r"..\题库0.3\Problems.json")
|
||||||
|
print(spareIDs(pro_dict))
|
||||||
|
|
||||||
Reference in New Issue