diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index 162af99f0efa..7fa9abc59a16 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -17,7 +17,7 @@ from . import qt_compat from .qt_compat import ( QtCore, QtGui, QtWidgets, __version__, QT_API, - _devicePixelRatioF, _isdeleted, _setDevicePixelRatioF, + _devicePixelRatioF, _isdeleted, _setDevicePixelRatio, ) backend_version = __version__ @@ -707,7 +707,7 @@ def _icon(self, name): if QtCore.qVersion() >= '5.': name = name.replace('.png', '_large.png') pm = QtGui.QPixmap(str(cbook._get_data_path('images', name))) - _setDevicePixelRatioF(pm, _devicePixelRatioF(self)) + _setDevicePixelRatio(pm, _devicePixelRatioF(self)) if self.palette().color(self.backgroundRole()).value() < 128: icon_color = self.palette().color(self.foregroundRole()) mask = pm.createMaskFromColor(QtGui.QColor('black'), diff --git a/lib/matplotlib/backends/backend_qt5agg.py b/lib/matplotlib/backends/backend_qt5agg.py index c46e493f9cf1..80e670b3f3e4 100644 --- a/lib/matplotlib/backends/backend_qt5agg.py +++ b/lib/matplotlib/backends/backend_qt5agg.py @@ -11,7 +11,7 @@ from .backend_qt5 import ( QtCore, QtGui, QtWidgets, _BackendQT5, FigureCanvasQT, FigureManagerQT, NavigationToolbar2QT, backend_version) -from .qt_compat import QT_API, _setDevicePixelRatioF +from .qt_compat import QT_API, _setDevicePixelRatio class FigureCanvasQTAgg(FigureCanvasAgg, FigureCanvasQT): @@ -64,7 +64,7 @@ def paintEvent(self, event): qimage = QtGui.QImage(buf, buf.shape[1], buf.shape[0], QtGui.QImage.Format_ARGB32_Premultiplied) - _setDevicePixelRatioF(qimage, self._dpi_ratio) + _setDevicePixelRatio(qimage, self._dpi_ratio) # set origin using original QT coordinates origin = QtCore.QPoint(rect.left(), rect.top()) painter.drawImage(origin, qimage) diff --git a/lib/matplotlib/backends/backend_qt5cairo.py b/lib/matplotlib/backends/backend_qt5cairo.py index d29997410323..c79b0bc22260 100644 --- a/lib/matplotlib/backends/backend_qt5cairo.py +++ b/lib/matplotlib/backends/backend_qt5cairo.py @@ -2,7 +2,7 @@ from .backend_cairo import cairo, FigureCanvasCairo, RendererCairo from .backend_qt5 import QtCore, QtGui, _BackendQT5, FigureCanvasQT -from .qt_compat import QT_API, _setDevicePixelRatioF +from .qt_compat import QT_API, _setDevicePixelRatio class FigureCanvasQTCairo(FigureCanvasQT, FigureCanvasCairo): @@ -33,7 +33,7 @@ def paintEvent(self, event): # QImage under PySide on Python 3. if QT_API == 'PySide': ctypes.c_long.from_address(id(buf)).value = 1 - _setDevicePixelRatioF(qimage, dpi_ratio) + _setDevicePixelRatio(qimage, dpi_ratio) painter = QtGui.QPainter(self) painter.eraseRect(event.rect()) painter.drawImage(0, 0, qimage) diff --git a/lib/matplotlib/backends/qt_compat.py b/lib/matplotlib/backends/qt_compat.py index e2c6e1f44215..4068afb5aaf3 100644 --- a/lib/matplotlib/backends/qt_compat.py +++ b/lib/matplotlib/backends/qt_compat.py @@ -206,15 +206,12 @@ def _devicePixelRatioF(obj): return 1 -def _setDevicePixelRatioF(obj, val): +def _setDevicePixelRatio(obj, val): """ - Call obj.setDevicePixelRatioF(val) with graceful fallback for older Qt. + Call obj.setDevicePixelRatio(val) with graceful fallback for older Qt. This can be replaced by the direct call when we require Qt>=5.6. """ - if hasattr(obj, 'setDevicePixelRatioF'): - # Not available on Qt<5.6 - obj.setDevicePixelRatioF(val) - elif hasattr(obj, 'setDevicePixelRatio'): + if hasattr(obj, 'setDevicePixelRatio'): # Not available on Qt4 or some older Qt5. obj.setDevicePixelRatio(val)