From 31776325b978fa6ca97f3f09bdc10d45befd87c9 Mon Sep 17 00:00:00 2001 From: Eric Firing Date: Mon, 4 Jul 2011 21:30:15 -1000 Subject: [PATCH] qt_for_kernel: use matplotlib rcParams to decide between PyQt4 and PySide This is a companion to a possible change in mpl, adding rcParams['backend.qt4'], but should work as well with earlier mpl versions. (There is still a problem with mpl in the ipython console when PySide is selected.) --- IPython/external/qt_for_kernel.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/IPython/external/qt_for_kernel.py b/IPython/external/qt_for_kernel.py index 573359e6cc6..4eb15cb32c3 100644 --- a/IPython/external/qt_for_kernel.py +++ b/IPython/external/qt_for_kernel.py @@ -6,7 +6,11 @@ # Older versions of matplotlib do not support PyQt4 v2 APIs or PySide, so we # cannot go through the preferred mechanism. matplotlib = sys.modules.get('matplotlib') -if matplotlib and matplotlib.__version__ <= '1.0.1': - from PyQt4 import QtCore, QtGui +if matplotlib: + mqt = matplotlib.rcParams.get('backend.qt4', 'PyQt4') + if mqt == 'PyQt4': + from PyQt4 import QtCore, QtGui + else: + from PySide import QtCore, QtGui else: from IPython.external.qt import QtCore, QtGui