Pyqt5—打开子窗口
展示run.py中的代码。
import sys from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow from PyQt5 import QtWidgets from window1 import Ui_MainWindow from window2 import Ui_MainWindow2 class mwindow1(QtWidgets.QMainWindow, Ui_MainWindow): def __init__(self): super(mwindow1, self).__init__() self.setupUi(self) # self.pushButton.clicked.connect(self.verify_account) # def verify_account(self): # account = self.lineEdit.text() #读取文本框内容 # password = self.lineEdit_2.text() # if (account == "123" and password =="123"): # msg_box = QtWidgets.QMessageBox # msg_box.information(self,"提示","成功登录!") class mwindow2(QtWidgets.QMainWindow, Ui_MainWindow2): def __init__(self): super(mwindow2, self).__init__() self.setupUi(self) def initUI(self): pass if __name__ == '__main__': app = QApplication(sys.argv) a = mwindow1() b = mwindow2() a.show() a.pushButton.clicked.connect(b.show) sys.exit(app.exec_())