Skip to content
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

Merged
merged 2 commits into from Oct 2, 2015

Conversation

tacaswell
Copy link
Member

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

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.
@tacaswell tacaswell added this to the next point release (1.5.0) milestone Sep 27, 2015
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
except ImportError:
# fell through, tried PyQt5, failed fall back to PyQt4
QT_API = rcParams['backend.qt4']
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok fair enough

Copy link
Member Author

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.

Copy link
Member

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

tacaswell added a commit that referenced this pull request Oct 2, 2015
MNT: more minor tweaks to qt_compat.py

Self merging so that I can tag 1.5.0rc2
@tacaswell tacaswell merged commit b61ff82 into matplotlib:master Oct 2, 2015
@tacaswell tacaswell deleted the mnt_qt_compat_again branch October 2, 2015 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants