# bug is many times the second child of pop-up window only in the first time to shut down through a window's close button signal and the program does not exit to the second child of pop-up window close button signal can't close the window, which bosses can help me have a look at what's going on, the code is as follows:
The from PySide2. QtWidgets import QWidget, QApplication QPushButton, QLabel
The import sys
The from PySide2. QtCore import Signal
Class secondWindow (QWidget) : # define the second pop-up window
Def __init__ (self) :
Super () __init__ ()
The self. The init ()
Def init (self) :
Self. SetWindowTitle (' the second window)
Self. SetGeometry (500200500500)
The self. The label=QLabel (self)
The self. The label. The setText (' this is the second window)
The self. The BTN=QPushButton (' closed ', the self)
The self. The BTN. SetGeometry (100100100)
The self. The BTN. Clicked. Connect (self. Close_window)
Def close_window (self) :
Print (' close the second window button signal has')
The self. The close ()
Class firstWindow (QWidget) : # define first pop-up window
Second_signal=Signal ()
Def __init__ (self) :
Super () __init__ ()
The self. The init ()
Def init (self) :
Self. SetWindowTitle (' first window)
The self. The resize (300300)
The self. The label=QLabel (self)
The self. The label. The setText (' this is the first window)
Self. BTN=QPushButton (' new window, self)
The self. The BTN. SetGeometry (100100100)
The self. The BTN. Clicked. Connect (self. Show_new_window)
Def show_new_window (self) :
Self. Second_signal. Emit () # custom window pops up the second signal channel
The class window (QWidget) : # define the main window
Def __init__ (self) :
Super () __init__ ()
The self. The initui ()
Def initui (self) :
Self. SetWindowTitle (' window ')
The self. The resize (500500)
The self. The BTN=QPushButton (' ready to pop up a new window, self)
The self. The BTN. SetGeometry (100100100)
The self. The BTN. Clicked. Connect (self. Show_new_window)
Def show_new_window (self) :
Self. First=firstWindow () # instantiate the first exposure to the pop-up
The self. The first. The show ()
Self. First. Second_signal. Connect (self. Show_second_window) # the first custom signal of groove, pop-up window to pop up the second window
Def show_second_window (self) :
# print (' signals have been issued to the second window popup)
The self. The second=secondWindow () # instantiation of the second pop-up window
The self. The second. The show ()
If __name__=="__main__" :
App=QApplication (sys. Argv)
Mywindow=window ()
Mywindow. The show ()
App. Exec_ ()