Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b61ff82

Browse filesBrowse files
committed
Merge pull request #5153 from tacaswell/mnt_qt_compat_again
MNT: more minor tweaks to qt_compat.py Self merging so that I can tag 1.5.0rc2
2 parents 5cd26aa + 938eb09 commit b61ff82
Copy full SHA for b61ff82

File tree

Expand file treeCollapse file tree

1 file changed

+14
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-4
lines changed

‎lib/matplotlib/backends/qt_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_compat.py
+14-4Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,18 @@
109109
except:
110110
res = 'QVariant API v2 specification failed. Defaulting to v1.'
111111
verbose.report(cond + res, 'helpful')
112+
if QT_API == QT_API_PYQT5:
113+
try:
114+
from PyQt5 import QtCore, QtGui, QtWidgets
115+
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
116+
except ImportError:
117+
# fell through, tried PyQt5, failed fall back to PyQt4
118+
QT_API = rcParams['backend.qt4']
119+
QT_RC_MAJOR_VERSION = 4
112120

121+
# needs to be if so we can re-test the value of QT_API which may
122+
# have been changed in the above if block
113123
if QT_API in [QT_API_PYQT, QT_API_PYQTv2]: # PyQt4 API
114-
115124
from PyQt4 import QtCore, QtGui
116125

117126
try:
@@ -131,9 +140,10 @@ def _getSaveFileName(*args, **kwargs):
131140
def _getSaveFileName(*args, **kwargs):
132141
return QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None
133142

134-
else: # PyQt5 API
135-
from PyQt5 import QtCore, QtGui, QtWidgets
136-
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
143+
else:
144+
raise RuntimeError("PyQt{4,5} bindings found despite sip importing\n"
145+
"Please install PyQt4 or PyQt5, uninstall sip or "
146+
"explicitly set the pyside backend.")
137147

138148
# Alias PyQt-specific functions for PySide compatibility.
139149
QtCore.Signal = QtCore.pyqtSignal

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.