From 61badc88b331661143ece2ee748fbf4c9acd8ec1 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Fri, 14 May 2021 05:27:20 +0800 Subject: [PATCH] implement pg.exec() --- pyqtgraph/Qt.py | 6 ++++++ pyqtgraph/__init__.py | 1 + 2 files changed, 7 insertions(+) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 6ae20cbb..eb5c6f32 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -450,3 +450,9 @@ def mkQApp(name=None): if name is not None: QAPP.setApplicationName(name) return QAPP + + +# exec() is used within _loadUiType, so we define as exec_() here and rename in pg namespace +def exec_(): + app = mkQApp() + return app.exec() if hasattr(app, 'exec') else app.exec_() diff --git a/pyqtgraph/__init__.py b/pyqtgraph/__init__.py index 916e937e..3edd7a20 100644 --- a/pyqtgraph/__init__.py +++ b/pyqtgraph/__init__.py @@ -11,6 +11,7 @@ __version__ = '0.12.1' ## 'Qt' is a local module; it is intended mainly to cover up the differences ## between PyQt4 and PySide. from .Qt import QtGui, mkQApp +from .Qt import exec_ as exec ## not really safe--If we accidentally create another QApplication, the process hangs (and it is very difficult to trace the cause) #if QtGui.QApplication.instance() is None: