app = QApplication.instance() if not app._main_wnd: for widget in app.topLevelWidgets(): if isinstance(widget, QMainWindow): app._main_wnd = widget return app._main_wnd else: return app._main_wnd return None if __name__ == '__main__': from ProjectDialog import ProjectDialog from MainWindow import MainWindow from ExceptionHandler import QExceptionHandler app = App(sys.argv) """ log for unhandled exception """ app.exception_handler = QExceptionHandler() app._excepthook = sys.excepthook sys.excepthook = app.exception_handler.handler dlg = ProjectDialog() if QDialog.Accepted == dlg.exec_(): if dlg.selected is not None: AppDocData.instance().current_project = dlg.selected main_wnd = MainWindow.instance() main_wnd.show() sys.exit(app.exec_())