I have a quite complicated PyQt app (Qt5, running in Spyder), where at the end I do
def main():
from PyQt5 import QtWidgets
if not QtWidgets.QApplication.instance():
app = QtWidgets.QApplication(sys.argv)
else:
app = QtWidgets.QApplication.instance()
main_window = MainWindow()
main_window.show()
status = app.exec_()
print status
sys.exit(0)
if __name__ == "__main__":
main()
(The if-else check is needed because of this(second answer).) When I run this code, my app shows, and the status code -1
is printed at the same time (due to a raised error in spyder/utils/ipython/start_kernel.py
). My question is, why this error is printed at all, because I thougt that app.exec_() is a blocking call and the status is not returned until the app is exited somehow. Is this due to Spyder running its own QApplication
?