Reputation: 1892
I have written small tool and works well. I would like to system testing where I can open window and close window to run high level flow. But I am not able to figure to close window through program. One silly option is, to kill process to close window but I feel there could be some better way.
Just sharing invoking code
self.logger.info("Running gui mode")
if self.approval:
app = QApplication([])
window = ApprovalWindow(app, self.block, self.mil,
self.vio, self.app,
self.prep, self.logger)
else:
app = QApplication([])
window = ReviewWindow(app, self.block, self.mil,
self.vio,
self.pre, self.logger)
window.create_widget()
window.show()
app.exec_()
Tried method
# app.close()
# for widget in appl.allwidgest():
# widget.close
Upvotes: 0
Views: 653
Reputation: 243897
If you want to terminate the application then you must use the quit()
method:
QCoreApplication.quit()
If instead you want to close all the windows then there are the following options:
Close all toplevel widgets:
for tl_widget in QApplication.topLevelWidgets():
tl_widget.close()
Close all QWindows
for window in QGuiApplication.topLevelWindows():
window.close()
Upvotes: 1