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