File tree 2 files changed +25
-2
lines changed 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -284,7 +284,20 @@ macosx Cocoa rendering in OSX windows
284
284
.. _TkInter : http://wiki.python.org/moin/TkInter
285
285
.. _PyQt4 : http://www.riverbankcomputing.co.uk/software/pyqt/intro
286
286
287
+ How do I select PyQt4 or PySide?
288
+ ========================================
287
289
290
+ You can choose either PyQt4 or PySide when using the `qt4 ` backend by setting
291
+ the appropriate value for `backend.qt4 ` in your :file: `matplotlibrc ` file. The
292
+ default value is `PyQt4 `.
293
+
294
+ The setting in your :file: `matplotlibrc ` file can be overridden by setting the
295
+ `QT_API ` environment variable to either `pyqt ` or `pyside ` to use `PyQt4 ` or
296
+ `PySide `, respectively.
297
+
298
+ Since the default value for the bindings to be used is `PyQt4 `,
299
+ :mod: `matplotlib ` first tries to import it, if the import fails, it tries to
300
+ import `PySide `.
288
301
289
302
.. _interactive-mode :
290
303
Original file line number Diff line number Diff line change 31
31
# of file dialog.
32
32
_getSaveFileName = None
33
33
34
+ # Flag to check if sip could be imported
35
+ _sip_imported = False
36
+
34
37
# Now perform the imports.
35
38
if QT_API in (QT_API_PYQT , QT_API_PYQTv2 ):
36
- import sip
39
+ try :
40
+ import sip
41
+ _sip_imported = True
42
+ except ImportError :
43
+ # Try using PySide
44
+ QT_API = QT_API_PYSIDE
45
+
46
+ if _sip_imported :
37
47
if QT_API == QT_API_PYQTv2 :
38
48
if QT_API_ENV == 'pyqt' :
39
49
cond = ("Found 'QT_API=pyqt' environment variable. "
76
86
# call to getapi() can fail in older versions of sip
77
87
_getSaveFileName = QtGui .QFileDialog .getSaveFileName
78
88
79
- else : # can only be pyside
89
+ else : # try importing pyside
80
90
from PySide import QtCore , QtGui , __version__ , __version_info__
81
91
if __version_info__ < (1 , 0 , 3 ):
82
92
raise ImportError (
You can’t perform that action at this time.
0 commit comments