FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Do not create a QApplication in Qt input hook · Issue #13617 · ipython/ipython · GitHub

Repository navigation

Do not create a QApplication in Qt input hook #13617

Open

Description

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.

Activity

  1. tacaswell commented on Apr 30, 2022

    ContributorAuthor

    https://gist.github.com/pag/f7d1ebbd1b14fe9058bf68d73a52bc84 is a patch that implements this a related idea that does not spin the event loop until it is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL