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

Skip to content

Commit 39b86d6

Browse files
committed
MNT: tweak the toolbar for Qt
Do not over-size the icons
1 parent a40620a commit 39b86d6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,9 @@ def __init__(self, canvas, parent, coordinates=True):
582582
def _icon(self, name):
583583
if is_pyqt5():
584584
name = name.replace('.png', '_large.png')
585-
return QtGui.QIcon(os.path.join(self.basedir, name))
585+
pm = QtGui.QPixmap(os.path.join(self.basedir, name))
586+
pm.setDevicePixelRatio(self.canvas._dpi_ratio)
587+
return QtGui.QIcon(pm)
586588

587589
def _init_toolbar(self):
588590
self.basedir = os.path.join(matplotlib.rcParams['datapath'], 'images')
@@ -592,7 +594,7 @@ def _init_toolbar(self):
592594
self.addSeparator()
593595
else:
594596
a = self.addAction(self._icon(image_file + '.png'),
595-
text, getattr(self, callback))
597+
text, getattr(self, callback))
596598
self._actions[callback] = a
597599
if callback in ['zoom', 'pan']:
598600
a.setCheckable(True)
@@ -614,7 +616,7 @@ def _init_toolbar(self):
614616
QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
615617
self.locLabel.setSizePolicy(
616618
QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
617-
QtWidgets.QSizePolicy.Ignored))
619+
QtWidgets.QSizePolicy.Ignored))
618620
labelAction = self.addWidget(self.locLabel)
619621
labelAction.setVisible(True)
620622

0 commit comments

Comments
 (0)