Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4308d39

Browse files
authored
Merge pull request #8315 from tacaswell/fix_qt_fallback
[MRG+1] FIX: if explicitly asked for Qt5 backend, do not fallback to qt4
2 parents b546822 + c52c024 commit 4308d39

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

lib/matplotlib/backends/qt_compat.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
# compatible use the env variable.
7171
QT_API = ETS[QT_API_ENV][0]
7272

73+
_fallback_to_qt4 = False
7374
if QT_API is None:
7475
# No ETS environment or incompatible so use rcParams.
7576
if rcParams['backend'] == 'Qt5Agg':
@@ -81,7 +82,7 @@
8182
# bindings is imported, but we still got here because a Qt
8283
# related file was imported. This is allowed, fall back to Qt5
8384
# using which ever binding the rparams ask for.
84-
85+
_fallback_to_qt4 = True
8586
QT_API = rcParams['backend.qt5']
8687

8788
# We will define an appropriate wrapper for the differing versions
@@ -127,9 +128,12 @@
127128
from PyQt5 import QtCore, QtGui, QtWidgets
128129
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
129130
except ImportError:
130-
# fell through, tried PyQt5, failed fall back to PyQt4
131-
QT_API = rcParams['backend.qt4']
132-
QT_RC_MAJOR_VERSION = 4
131+
if _fallback_to_qt4:
132+
# fell through, tried PyQt5, failed fall back to PyQt4
133+
QT_API = rcParams['backend.qt4']
134+
QT_RC_MAJOR_VERSION = 4
135+
else:
136+
raise
133137

134138
# needs to be if so we can re-test the value of QT_API which may
135139
# have been changed in the above if block

0 commit comments

Comments
 (0)