def find_window(name): for widget in QApplication.topLevelWidgets(): if widget.objectName() == name: return widget return None
def close_msg_boxes(): for w in QApplication.topLevelWidgets(): if isinstance(w, QMessageBox): print('Closing message box') QTest.keyClick(w, Qt.Key_Enter)