PyQT5 实现窗口跳转并关闭上一个窗口(多窗口跳转)


 本篇博客对应的视频讲解:https://www.bilibili.com/video/BV1NZ4y1Z7ue/

 

import sys
from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication


class First(QMainWindow):
    def __init__(self):
        super().__init__()

        self.initUI()
    def closewin(self):
        self.close()

    def initUI(self):
        self.btn = QPushButton("Button", self)
        self.btn.move(30, 50)

        self.setGeometry(300, 300, 500, 500)
        self.setWindowTitle('Event sender')
        self.show()

class Second(QMainWindow):
    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):
        self.setGeometry(300, 300, 290, 150)
        self.setWindowTitle('Get sender')


if __name__ == '__main__':
    app = QApplication(sys.argv)
    a = First()
    b = Second()
    a.show()
    a.btn.clicked.connect(a.closewin)
    a.btn.clicked.connect(b.show)
    sys.exit(app.exec_())

 

 

REF

https://www.cnblogs.com/jieliu8080/p/10552510.html

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM