Skip to content

Commit

Permalink
Try importing PySide, if we can't find sip.
Browse files Browse the repository at this point in the history
If no QT_API is specified, we use the value in rcParams and the
default value for this is PyQt.  If a user has PySide installed,
trying to use the qt backend fails, unless QT_API is specified or the
config file is modified.  This commit, adds code to try and import
PySide, if an import of PyQt fails.
  • Loading branch information
punchagan committed Jul 6, 2013
1 parent 43bf56e commit 5ce866c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/matplotlib/backends/qt4_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,19 @@
# of file dialog.
_getSaveFileName = None

# Flag to check if sip could be imported
_sip_imported = False

# Now perform the imports.
if QT_API in (QT_API_PYQT, QT_API_PYQTv2):
import sip
try:
import sip
_sip_imported = True
except ImportError:
# Try using PySide
QT_API = QT_API_PYSIDE

if _sip_imported:
if QT_API == QT_API_PYQTv2:
if QT_API_ENV == 'pyqt':
cond = ("Found 'QT_API=pyqt' environment variable. "
Expand Down Expand Up @@ -76,7 +86,7 @@
# call to getapi() can fail in older versions of sip
_getSaveFileName = QtGui.QFileDialog.getSaveFileName

else: # can only be pyside
else: # try importing pyside
from PySide import QtCore, QtGui, __version__, __version_info__
if __version_info__ < (1, 0, 3):
raise ImportError(
Expand Down

0 comments on commit 5ce866c

Please sign in to comment.