implement pg.exec()

This commit is contained in:
KIU Shueng Chuan 2021-05-14 05:27:20 +08:00
parent 1905f83047
commit 61badc88b3
2 changed files with 7 additions and 0 deletions

View File

@ -450,3 +450,9 @@ def mkQApp(name=None):
if name is not None: if name is not None:
QAPP.setApplicationName(name) QAPP.setApplicationName(name)
return QAPP 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_()

View File

@ -11,6 +11,7 @@ __version__ = '0.12.1'
## 'Qt' is a local module; it is intended mainly to cover up the differences ## 'Qt' is a local module; it is intended mainly to cover up the differences
## between PyQt4 and PySide. ## between PyQt4 and PySide.
from .Qt import QtGui, mkQApp 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) ## 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: #if QtGui.QApplication.instance() is None: