Answer the question
In order to leave comments, you need to log in
How did it happen that it works :)?
There is this code:
class BugWindow (QtGui.QWidget, Create_bug_report.Ui_Bug):
def __init__(self, parent=None, flags=None):
QtGui.QWidget.__init__(self, parent)
self.setWindowFlags(flags)
self.setupUi(self)
def __call__(self):
#print(self.parentWidget())
self.show()
....
try:
...
raise FileNotFoundError
except FileNotFoundError as e:
app = QtGui.QApplication(sys.argv)
bug_window = BugWindow(flags=QtCore.Qt.Window)
bug_window.show()
bug_window.err_label.setText(r'<html><head/><body><p align="center"><span style=" font-size:10pt; font-weight:600;">Error message:</span></p><p>'+str(e) +r'</p><p> </p></body></html>')
sys.exit(bug_window.exec_())
finally:
cnfg.write(options_file)
options_file.close
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
The 'window close button click' event closes the window by default, but does not kill the main event-loop fired by the 'app.exec_()' statement.
The QApplication event-loop usually stops itself when the last opened window closes.
But this only applies to windows without a parent and with the Qt.WA_QuitOnClose flag.
pyqt.sourceforge.net/Docs/PyQt4/qapplication.html#...
Perhaps this flag is not set on the BugWindow.
You can add this flag to the BugWindow widget:
bug_window.setWindowFlags(bug_window.windowFlags() | QtCore.Qt.WA_QuitOnClose)
Or bind the 'window closed' event to a stop/kill event-loop:
class BugWindow(...):
def __init__ (...):
self.closed.connect(QtCore.QCoreApplication.instance().quit)
zetcode.com/gui/pyqt4/firstprograms
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question