Currently if the Qt input hook runs and there is not as exiting QApplication IPython will create one for the user and then spin it. On one hand this is convenient for doing Qt work as the Application is automatically created after the first cell runs. However, this can lead to weird behavior where running commands in one line vs serval cells leads to different results (see DeepLabCut/DeepLabCut#1730).
Although I advocated for the current state of affairs, I now think that it is more confusing this way. I propose that basically this entire block of code is removed and replaced with return
|
if sys.platform == 'linux': |
|
if not os.environ.get('DISPLAY') \ |
|
and not os.environ.get('WAYLAND_DISPLAY'): |
|
import warnings |
|
global _already_warned |
|
if not _already_warned: |
|
_already_warned = True |
|
warnings.warn( |
|
'The DISPLAY or WAYLAND_DISPLAY environment variable is ' |
|
'not set or empty and Qt5 requires this environment ' |
|
'variable. Deactivate Qt5 code.' |
|
) |
|
return |
|
try: |
|
QtCore.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) |
|
except AttributeError: # Only for Qt>=5.6, <6. |
|
pass |
|
try: |
|
QtCore.QApplication.setHighDpiScaleFactorRoundingPolicy( |
|
QtCore.Qt.HighDpiScaleFactorRoundingPolicy.PassThrough |
|
) |
|
except AttributeError: # Only for Qt>=5.14. |
|
pass |
|
_appref = app = QtGui.QApplication([" "]) |
|
|
|
# "reclaim" IPython sys.excepthook after event loop starts |
|
# without this, it defaults back to BaseIPythonApplication.excepthook |
|
# and exceptions in the Qt event loop are rendered without traceback |
|
# formatting and look like "bug in IPython". |
|
QtCore.QTimer.singleShot(0, _reclaim_excepthook) |
A bulk of the work on this issue will be documenting the consequences and thinking through what the consequences might be.
Currently if the Qt input hook runs and there is not as exiting QApplication IPython will create one for the user and then spin it. On one hand this is convenient for doing Qt work as the Application is automatically created after the first cell runs. However, this can lead to weird behavior where running commands in one line vs serval cells leads to different results (see DeepLabCut/DeepLabCut#1730).
Although I advocated for the current state of affairs, I now think that it is more confusing this way. I propose that basically this entire block of code is removed and replaced with
returnipython/IPython/terminal/pt_inputhooks/qt.py
Lines 27 to 56 in 6ddb518
A bulk of the work on this issue will be documenting the consequences and thinking through what the consequences might be.