主窗口打开子窗口,通过子窗口执行后面的代码

# !/usr/local/bin/python
# coding:utf-8
from PyQt5 import QtCore
from PyQt5.QtWidgets import *
import sys


class App(QWidget):
    def __init__(self):
        super().__init__()
        self.win_main()

    def win_main(self):
        self.resize(600, 200)
        self.add_button = QPushButton("添加", self)
        self.add_button.resize(200, 60)
        self.add_button.move(150, 10)
        self.add_button.clicked.connect(lambda: self.win_add_zhege())
        self.show()

    def win_add_zhege(self):
        # self.close()
        print("1")
        self.win_add_func()

    def win_add_func(self):
        print("2")
        self.win_add = QWidget()
        self.win_add.resize(300, 700)
        self.win_add.setWindowTitle("提示")
        self.win_add.setWindowModality(QtCore.Qt.ApplicationModal)
        self.layout1 = QHBoxLayout(self.win_add)
        self.btn = QPushButton('ok', self.win_add)
        self.btn.resize(200, 60)
        self.btn.move(150, 10)
        self.layout1.addWidget(self.btn)
        self.btn.clicked.connect(self.print_info)

        print("3")
        self.win_add.show()
        print("4")

    def print_info(self):
        print('5')


if __name__ == '__main__':
    app = QApplication(sys.argv)
    a = App()
    sys.exit(app.exec_())

 

上一篇:微信公众号h5页面跳转小程序开发踩坑


下一篇:小程序单选框 radio