From 3e68c8e6118c69989ff342e6aa1bebfdf1c132a7 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 3 Nov 2020 09:09:40 +0100 Subject: [PATCH] Remove fallback to nonexistent setDevicePixelRatioF. setDevicePixelRatioF never existed. --- lib/matplotlib/backends/backend_qt5.py | 4 ++-- lib/matplotlib/backends/backend_qt5agg.py | 4 ++-- lib/matplotlib/backends/backend_qt5cairo.py | 4 ++-- lib/matplotlib/backends/qt_compat.py | 9 +++------ 4 files changed, 9 insertions(+), 12 deletions(-) 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) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy