def _doit(factory): try: app = QApplication([]) except RuntimeError: app = QCoreApplication.instance() main_window = factory() if getattr(sys, '_called_from_test', False) and is_windows_platform(): QTimer.singleShot(500, app, Slot('quit()')) main_window.show() app.exec_()
def _func(*args, **kwargs): app = QCoreApplication.instance() if app is None: return func(*args, **kwargs) runner = Runner() try: runner.moveToThread(app.thread()) app.notify(runner, Event(func, args, kwargs)) return runner.result.get() finally: runner.deleteLater()
def _doit(factory): # for windows these needs to be repeated due to multiprocessing (?) from Qt.QtWidgets import QApplication from Qt.QtCore import QCoreApplication try: app = QApplication([]) except RuntimeError: app = QCoreApplication.instance() main_window = factory() if getattr(sys, '_called_from_test', False) and (is_windows_platform() or is_macos_platform()): QTimer.singleShot(1000, app.quit) main_window.show() app.exec_()
def start(self): self._background_thread.start() QCoreApplication.instance().aboutToQuit.connect(self.stop)