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

Skip to content

Commit 23be033

Browse files
authored
Merge pull request #22152 from meeseeksmachine/auto-backport-of-pr-22135-on-v3.5.x
Backport PR #22135 on branch v3.5.x (Fix loading user-defined icons for Qt plot window)
2 parents 99b26be + 05973f3 commit 23be033

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/backends/backend_qt.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,14 @@ def _icon(self, name):
677677
Construct a `.QIcon` from an image file *name*, including the extension
678678
and relative to Matplotlib's "images" data directory.
679679
"""
680-
name = name.replace('.png', '_large.png')
681-
pm = QtGui.QPixmap(str(cbook._get_data_path('images', name)))
680+
# use a high-resolution icon with suffix '_large' if available
681+
# note: user-provided icons may not have '_large' versions
682+
path_regular = cbook._get_data_path('images', name)
683+
path_large = path_regular.with_name(
684+
path_regular.name.replace('.png', '_large.png'))
685+
filename = str(path_large if path_large.exists() else path_regular)
686+
687+
pm = QtGui.QPixmap(filename)
682688
_setDevicePixelRatio(pm, _devicePixelRatioF(self))
683689
if self.palette().color(self.backgroundRole()).value() < 128:
684690
icon_color = self.palette().color(self.foregroundRole())

0 commit comments

Comments
 (0)