PyQt5实现从主窗口打开子窗口的方法
1.在Qt Designer中设计两个简单窗口
2.将.ui文件转换成.py文件
3.新建**.py文件
#-*- coding:utf-8 -*- from PyQt5.QtWidgets import QMainWindow, QApplication from window import Ui_MainWindow from child import Ui_Child import sys class Main(QMainWindow,Ui_MainWindow): def __init__(self): super(Main, self).__init__() self.setupUi(self) class Child(QMainWindow,Ui_Child): def __init__(self): super(Child, self).__init__() self.setupUi(self) self.pushButton.clicked.connect(self.close) def OPEN(self): self.show() if __name__ =="__main__": app = QApplication(sys.argv) main = Main() ch = Child() main.show() main.pushButton.clicked.connect(ch.OPEN) sys.exit(app.exec_())
相关推荐
meylovezn 2020-09-15
zhongfuyu 2020-08-16
JimyFengqi 2020-08-16
追逐阳光的风 2020-07-04
hustlei 2020-06-21
lianback 2020-06-21
王磊的程序员之路 2020-06-21
kikaylee 2020-06-12
生物信息学 2020-06-07
hustlei 2020-06-04
zhongfuyu 2020-05-30
hustlei 2020-05-19
zhongfuyu 2020-05-19
zhongfuyu 2020-05-14
JasonYeung 2020-05-09