-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MNT: more minor tweaks to qt_compat.py #5153
Conversation
If we the backend is not a Qt* backend, a version of pyqt has not been imported and PyQt5 is not installed qt_compat would raise as ImportError. Now it will gracefully fall back to PyQt4.
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName | ||
except ImportError: | ||
# fell through, tried PyQt5, failed fall back to PyQt4 | ||
QT_API = rcParams['backend.qt4'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would raise a warning here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the logic has gotten crossed here. You can fall through this code path as the 'right' thing to do if we had to guess about qt4vqt5 above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I misunderstand, but as far as I can see that will only happen if
- You have specified
rcParams['backend.qt4'] = PyQt5
which is clearly wrong. - Tried using the Qt5Agg backend without installing PyQt5
- if
if "PyQt4" in sys.modules or "PySide" in sys.modules:
fails if which case this will fail any way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also get here if your rcparam is tkagg and you do not have qt5
installed (which is how I found this).
The (new) logic above says that if the rcparam is not set to a qt flavor,
it looks to see if qt4 or pyside is imported, then assumes it should be
using qt5.
On Mon, Sep 28, 2015, 04:30 Jens Hedegaard Nielsen notifications@github.com
wrote:
In lib/matplotlib/backends/qt_compat.py
#5153 (comment):@@ -109,9 +109,18 @@
except:
res = 'QVariant API v2 specification failed. Defaulting to v1.'
verbose.report(cond + res, 'helpful')
- if QT_API == QT_API_PYQT5:
try:
from PyQt5 import QtCore, QtGui, QtWidgets
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
except ImportError:
# fell through, tried PyQt5, failed fall back to PyQt4
QT_API = rcParams['backend.qt4']
Perhaps I misunderstand, but as far as I can see that will only happen if
- You have specified rcParams['backend.qt4'] = PyQt5 which is clearly
wrong.- Tried using the Qt5Agg backend without installing PyQt5
- if if "PyQt4" in sys.modules or "PySide" in sys.modules: fails if
which case this will fail any way.—
Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/5153/files#r40527986.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok fair enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this thing is a mess and needs a overhaul, but i want to get it
fixed enough for the next rc
On Mon, Sep 28, 2015, 06:59 Jens Hedegaard Nielsen notifications@github.com
wrote:
In lib/matplotlib/backends/qt_compat.py
#5153 (comment):@@ -109,9 +109,18 @@
except:
res = 'QVariant API v2 specification failed. Defaulting to v1.'
verbose.report(cond + res, 'helpful')
- if QT_API == QT_API_PYQT5:
try:
from PyQt5 import QtCore, QtGui, QtWidgets
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
except ImportError:
# fell through, tried PyQt5, failed fall back to PyQt4
QT_API = rcParams['backend.qt4']
Ok fair enough
—
Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/5153/files#r40539934.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, part of the mess is my fault
MNT: more minor tweaks to qt_compat.py Self merging so that I can tag 1.5.0rc2
If we the backend is not a Qt* backend, a version of pyqt has not been
imported and PyQt5 is not installed qt_compat would raise as
ImportError. Now it will gracefully fall back to PyQt4.
attn @jrevans @mfitzp