Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3460e0e

Browse files
authored
Merge pull request #17640 from QuLogic/more-pyqt5-fixes
More qt fractional DPI fixes
2 parents 77f23da + 5b6e92a commit 3460e0e

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from . import qt_compat
1919
from .qt_compat import (
2020
QtCore, QtGui, QtWidgets, __version__, QT_API,
21-
_devicePixelRatioF, _isdeleted,
21+
_devicePixelRatioF, _isdeleted, _setDevicePixelRatioF,
2222
)
2323

2424
backend_version = __version__
@@ -710,7 +710,7 @@ def _icon(self, name):
710710
if QtCore.qVersion() >= '5.':
711711
name = name.replace('.png', '_large.png')
712712
pm = QtGui.QPixmap(str(cbook._get_data_path('images', name)))
713-
qt_compat._setDevicePixelRatio(pm, _devicePixelRatioF(self))
713+
_setDevicePixelRatioF(pm, _devicePixelRatioF(self))
714714
if self.palette().color(self.backgroundRole()).value() < 128:
715715
icon_color = self.palette().color(self.foregroundRole())
716716
mask = pm.createMaskFromColor(QtGui.QColor('black'),

lib/matplotlib/backends/qt_compat.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
def _setup_pyqt5():
6969
global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, \
70-
_isdeleted, _devicePixelRatio, _setDevicePixelRatio, _getSaveFileName
70+
_isdeleted, _getSaveFileName
7171

7272
if QT_API == QT_API_PYQT5:
7373
from PyQt5 import QtCore, QtGui, QtWidgets
@@ -89,14 +89,10 @@ def _isdeleted(obj): return not shiboken2.isValid(obj)
8989
def is_pyqt5():
9090
return True
9191

92-
# self.devicePixelRatio() returns 0 in rare cases
93-
def _devicePixelRatio(obj): return obj.devicePixelRatio() or 1
94-
def _setDevicePixelRatio(obj, factor): obj.setDevicePixelRatio(factor)
95-
9692

9793
def _setup_pyqt4():
9894
global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, \
99-
_isdeleted, _devicePixelRatio, _setDevicePixelRatio, _getSaveFileName
95+
_isdeleted, _getSaveFileName
10096

10197
def _setup_pyqt4_internal(api):
10298
global QtCore, QtGui, QtWidgets, \
@@ -149,9 +145,6 @@ def _isdeleted(obj): return not shiboken.isValid(obj)
149145
def is_pyqt5():
150146
return False
151147

152-
def _devicePixelRatio(obj): return 1
153-
def _setDevicePixelRatio(obj, factor): pass
154-
155148

156149
if QT_API in [QT_API_PYQT5, QT_API_PYSIDE2]:
157150
_setup_pyqt5()
@@ -220,6 +213,6 @@ def _setDevicePixelRatioF(obj, val):
220213
if hasattr(obj, 'setDevicePixelRatioF'):
221214
# Not available on Qt<5.6
222215
obj.setDevicePixelRatioF(val)
223-
if hasattr(obj, 'setDevicePixelRatio'):
216+
elif hasattr(obj, 'setDevicePixelRatio'):
224217
# Not available on Qt4 or some older Qt5.
225218
obj.setDevicePixelRatio(val)

0 commit comments

Comments
 (0)