from PySide6.QtWidgets import QWidget, QApplication, QFileDialog from Ui_寻找空闲题号 import Ui_Form from database_tools import * 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]) self.ShowAvailable() if __name__ == '__main__': app = QApplication([]) windows = MyWindow() windows.show() app.exec()