Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Also use light color tool buttons in qt+toolmanager+dark theme. #17365

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
merged 1 commit into from
May 8, 2020
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
25 changes: 6 additions & 19 deletions 25 lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,16 +654,11 @@ def __init__(self, canvas, parent, coordinates=True):
self.coordinates = coordinates
self._actions = {} # mapping of toolitem method names to QActions.

background_color = self.palette().color(self.backgroundRole())
foreground_color = self.palette().color(self.foregroundRole())
icon_color = (foreground_color
if background_color.value() < 128 else None)

for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
self.addSeparator()
else:
a = self.addAction(self._icon(image_file + '.png', icon_color),
a = self.addAction(self._icon(image_file + '.png'),
text, getattr(self, callback))
self._actions[callback] = a
if callback in ['zoom', 'pan']:
Expand Down Expand Up @@ -695,15 +690,16 @@ def __init__(self, canvas, parent, coordinates=True):
def basedir(self):
return str(cbook._get_data_path('images'))

def _icon(self, name, color=None):
def _icon(self, name):
if QtCore.QT_VERSION_STR >= '5.':
name = name.replace('.png', '_large.png')
pm = QtGui.QPixmap(str(cbook._get_data_path('images', name)))
qt_compat._setDevicePixelRatio(pm, qt_compat._devicePixelRatio(self))
if color is not None:
if self.palette().color(self.backgroundRole()).value() < 128:
icon_color = self.palette().color(self.foregroundRole())
mask = pm.createMaskFromColor(QtGui.QColor('black'),
QtCore.Qt.MaskOutColor)
pm.fill(color)
pm.fill(icon_color)
pm.setMask(mask)
return QtGui.QIcon(pm)

Expand Down Expand Up @@ -891,15 +887,11 @@ def __init__(self, toolmanager, parent):
self._toolitems = {}
self._groups = {}

@property
def _icon_extension(self):
return '_large.png' if QtCore.QT_VERSION_STR >= '5.' else '.png'

def add_toolitem(
self, name, group, position, image_file, description, toggle):

button = QtWidgets.QToolButton(self)
button.setIcon(self._icon(image_file))
button.setIcon(NavigationToolbar2QT._icon(self, image_file))
button.setText(name)
if description:
button.setToolTip(description)
Expand All @@ -926,11 +918,6 @@ def _add_to_group(self, group, name, button, position):
gr.insert(position, widget)
self._groups[group] = gr

def _icon(self, name):
pm = QtGui.QPixmap(name)
qt_compat._setDevicePixelRatio(pm, self.toolmanager.canvas._dpi_ratio)
return QtGui.QIcon(pm)

def toggle_toolitem(self, name, toggled):
if name not in self._toolitems:
return
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.