Skip to content

Commit eeef6e5

Browse files
authored
Merge pull request #18877 from anntzer/sdpr
Remove fallback to nonexistent setDevicePixelRatioF.
2 parents 1c20824 + 3e68c8e commit eeef6e5

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

lib/matplotlib/backends/backend_qt5.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from . import qt_compat
1818
from .qt_compat import (
1919
QtCore, QtGui, QtWidgets, __version__, QT_API,
20-
_devicePixelRatioF, _isdeleted, _setDevicePixelRatioF,
20+
_devicePixelRatioF, _isdeleted, _setDevicePixelRatio,
2121
)
2222

2323
backend_version = __version__
@@ -707,7 +707,7 @@ def _icon(self, name):
707707
if QtCore.qVersion() >= '5.':
708708
name = name.replace('.png', '_large.png')
709709
pm = QtGui.QPixmap(str(cbook._get_data_path('images', name)))
710-
_setDevicePixelRatioF(pm, _devicePixelRatioF(self))
710+
_setDevicePixelRatio(pm, _devicePixelRatioF(self))
711711
if self.palette().color(self.backgroundRole()).value() < 128:
712712
icon_color = self.palette().color(self.foregroundRole())
713713
mask = pm.createMaskFromColor(QtGui.QColor('black'),

lib/matplotlib/backends/backend_qt5agg.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .backend_qt5 import (
1212
QtCore, QtGui, QtWidgets, _BackendQT5, FigureCanvasQT, FigureManagerQT,
1313
NavigationToolbar2QT, backend_version)
14-
from .qt_compat import QT_API, _setDevicePixelRatioF
14+
from .qt_compat import QT_API, _setDevicePixelRatio
1515

1616

1717
class FigureCanvasQTAgg(FigureCanvasAgg, FigureCanvasQT):
@@ -64,7 +64,7 @@ def paintEvent(self, event):
6464

6565
qimage = QtGui.QImage(buf, buf.shape[1], buf.shape[0],
6666
QtGui.QImage.Format_ARGB32_Premultiplied)
67-
_setDevicePixelRatioF(qimage, self._dpi_ratio)
67+
_setDevicePixelRatio(qimage, self._dpi_ratio)
6868
# set origin using original QT coordinates
6969
origin = QtCore.QPoint(rect.left(), rect.top())
7070
painter.drawImage(origin, qimage)

lib/matplotlib/backends/backend_qt5cairo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from .backend_cairo import cairo, FigureCanvasCairo, RendererCairo
44
from .backend_qt5 import QtCore, QtGui, _BackendQT5, FigureCanvasQT
5-
from .qt_compat import QT_API, _setDevicePixelRatioF
5+
from .qt_compat import QT_API, _setDevicePixelRatio
66

77

88
class FigureCanvasQTCairo(FigureCanvasQT, FigureCanvasCairo):
@@ -33,7 +33,7 @@ def paintEvent(self, event):
3333
# QImage under PySide on Python 3.
3434
if QT_API == 'PySide':
3535
ctypes.c_long.from_address(id(buf)).value = 1
36-
_setDevicePixelRatioF(qimage, dpi_ratio)
36+
_setDevicePixelRatio(qimage, dpi_ratio)
3737
painter = QtGui.QPainter(self)
3838
painter.eraseRect(event.rect())
3939
painter.drawImage(0, 0, qimage)

lib/matplotlib/backends/qt_compat.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,12 @@ def _devicePixelRatioF(obj):
206206
return 1
207207

208208

209-
def _setDevicePixelRatioF(obj, val):
209+
def _setDevicePixelRatio(obj, val):
210210
"""
211-
Call obj.setDevicePixelRatioF(val) with graceful fallback for older Qt.
211+
Call obj.setDevicePixelRatio(val) with graceful fallback for older Qt.
212212
213213
This can be replaced by the direct call when we require Qt>=5.6.
214214
"""
215-
if hasattr(obj, 'setDevicePixelRatioF'):
216-
# Not available on Qt<5.6
217-
obj.setDevicePixelRatioF(val)
218-
elif hasattr(obj, 'setDevicePixelRatio'):
215+
if hasattr(obj, 'setDevicePixelRatio'):
219216
# Not available on Qt4 or some older Qt5.
220217
obj.setDevicePixelRatio(val)

0 commit comments

Comments
 (0)