I am using PyQT to create QMainWindow window that opens another window when a button is clicked. My problem is that the popup window remains displayed even if I close the main window which spawned it. This is very similar with the one posted here but written in C++ and I can only do Python. How can I implement the answer in Python? Here is my code:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import sys
class Pycryptor:
def mainGui(self):
app = QApplication(sys.argv)
#MainWindow
self.mainWin = QMainWindow()
self.mainWin.setGeometry(200,200,500,432)
self.mainWin.show()
#MenuBar
mainMenu = self.mainWin.menuBar()
mainMenu.setNativeMenuBar(False)
aboutMenu = mainMenu.addMenu('A&bout')
helpButton = QAction(QIcon(),'Help',self.mainWin)
helpButton.triggered.connect(self.helpPopup)
aboutMenu.addAction(helpButton)
sys.exit(app.exec_())
def helpPopup(self):
self.popup = HelpWindow()
self.popup.setGeometry(800,200,300,500)
self.popup.show()
class HelpWindow(QWidget):
def __init__(self):
QWidget.__init__(self)
if __name__ == '__main__':
p = Pycryptor()
p.mainGui()