Skip to content

Commit

Permalink
Python Console: Fix plotting with the Qt4 backend
Browse files Browse the repository at this point in the history
Fixes #2231
  • Loading branch information
ccordoba12 committed Apr 1, 2015
1 parent 1896cbc commit 6bbd031
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions spyderlib/widgets/externalshell/sitecustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def qt_nt_inputhook():

# Setting the right input hook according to mpl_backend,
# IMPORTANT NOTE: Don't try to abstract the steps to set a PyOS
# input hook callback in a function. It will *crash* the
# input hook callback in a function. It will **crash** the
# interpreter!!
if mpl_backend == "Qt4Agg" and os.name == 'nt' and \
monitor is not None:
Expand All @@ -355,9 +355,13 @@ def qt_nt_inputhook():
callback = inputhooks.set_pyft_callback(qt_nt_inputhook)
pyos_ih = inputhooks.get_pyos_inputhook()
pyos_ih.value = ctypes.cast(callback, ctypes.c_void_p).value
elif mpl_backend == "Qt4Agg" and os.environ["QT_API"] == 'pyside':
# PySide doesn't have an input hook, so we need to install one
# to be able to show plots.
elif mpl_backend == "Qt4Agg":
# PyQt4 input hook stopped working after we moved to the new
# style for signals and slots, so we need to install our own
if os.environ["QT_API"] == 'pyqt':
inputhooks.remove_pyqt_inputhook()
# This works for both PySide (which doesn't have an input hook)
# and PyQt4 (whose input hook needs to be replaced, see above).
# Note: This only works well for Posix systems
callback = inputhooks.set_pyft_callback(inputhooks.qt4)
pyos_ih = inputhooks.get_pyos_inputhook()
Expand Down

0 comments on commit 6bbd031

Please sign in to comment.