Skip to content

Fix AttributeError: 'QPixmap' object has no attribute 'setDevicePixelRatio' #8559

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

Merged
merged 1 commit into from
May 3, 2017
Merged

Conversation

cgohlke
Copy link
Contributor

@cgohlke cgohlke commented May 2, 2017

Re #8440.
Using matplotlib-2.0.1 with PyQt4‑4.11.4, the example embedding_in_qt4_wtoolbar.py fails:

X:\Python36\lib\site-packages\matplotlib\backends\qt4_compat.py:10: MatplotlibDeprecationWarning: This module has been deprecated in 1.4 in favor of matplotlib.backends.qt_compat
This module will be removed in 1.5, please update your imports.
  warnings.warn(_warn_str, mplDeprecation)
Traceback (most recent call last):
  File "embedding_in_qt4_wtoolbar.py", line 74, in <module>
    main()
  File "embedding_in_qt4_wtoolbar.py", line 69, in main
    form = AppForm()
  File "embedding_in_qt4_wtoolbar.py", line 27, in __init__
    self.create_main_frame()
  File "embedding_in_qt4_wtoolbar.py", line 39, in create_main_frame
    self.mpl_toolbar = NavigationToolbar(self.canvas, self.main_frame)
  File "X:\Python36\lib\site-packages\matplotlib\backends\backend_qt5.py", line 585, in __init__
    NavigationToolbar2.__init__(self, canvas)
  File "X:\Python36\lib\site-packages\matplotlib\backend_bases.py", line 2760, in __init__
    self._init_toolbar()
  File "X:\Python36\lib\site-packages\matplotlib\backends\backend_qt5.py", line 601, in _init_toolbar
    a = self.addAction(self._icon(image_file + '.png'),
  File "X:\Python36\lib\site-packages\matplotlib\backends\backend_qt5.py", line 591, in _icon
    pm.setDevicePixelRatio(self.canvas._dpi_ratio)
AttributeError: 'QPixmap' object has no attribute 'setDevicePixelRatio'

@WeatherGod
Copy link
Member

attn: @efiring

Copy link
Member

@efiring efiring left a comment

Choose a reason for hiding this comment

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

This looks right to me, and appears to be the only place where the conditional was missed.

@efiring efiring changed the title Fix AttributeError: 'QPixmap' object has no attribute 'setDevicePixelRatio' [MRG+1] Fix AttributeError: 'QPixmap' object has no attribute 'setDevicePixelRatio' May 2, 2017
@tacaswell tacaswell merged commit f92e79c into matplotlib:v2.0.x May 3, 2017
@QuLogic QuLogic added this to the 2.0.2 (next bug fix release) milestone May 3, 2017
@QuLogic QuLogic changed the title [MRG+1] Fix AttributeError: 'QPixmap' object has no attribute 'setDevicePixelRatio' Fix AttributeError: 'QPixmap' object has no attribute 'setDevicePixelRatio' May 3, 2017
@tacaswell tacaswell modified the milestones: 2.0.3 (next bug fix release), 2.0.2 (critical bug fixes from 2.0.1) May 7, 2017
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.

5 participants