Skip to content

Backport PR #22135 on branch v3.5.x (Fix loading user-defined icons for Qt plot window) #22152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/matplotlib/backends/backend_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,14 @@ def _icon(self, name):
Construct a `.QIcon` from an image file *name*, including the extension
and relative to Matplotlib's "images" data directory.
"""
name = name.replace('.png', '_large.png')
pm = QtGui.QPixmap(str(cbook._get_data_path('images', name)))
# use a high-resolution icon with suffix '_large' if available
# note: user-provided icons may not have '_large' versions
path_regular = cbook._get_data_path('images', name)
path_large = path_regular.with_name(
path_regular.name.replace('.png', '_large.png'))
filename = str(path_large if path_large.exists() else path_regular)

pm = QtGui.QPixmap(filename)
_setDevicePixelRatio(pm, _devicePixelRatioF(self))
if self.palette().color(self.backgroundRole()).value() < 128:
icon_color = self.palette().color(self.foregroundRole())
Expand Down