def main(): app = QApplication(sys.argv) main_window = MainWindow() main_window.show() r = app.exec_() main_window.cleanup() sys.exit(r)