8000 Merge pull request #17540 from QuLogic/fix-gtk-help · matplotlib/matplotlib@e53a00c · GitHub
[go: up one dir, main page]

Skip to content

Commit e53a00c

Browse files
authored
Merge pull request #17540 from QuLogic/fix-gtk-help
FIX: help window on GTK.
2 parents 9127525 + 914c910 commit e53a00c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/matplotlib/backend_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class _ToolEnableNavigation(ToolBase):
430430
"""Tool to enable a specific axes for toolmanager interaction."""
431431

432432
description = 'Enable one axes toolmanager'
433-
default_keymap = (1, 2, 3, 4, 5, 6, 7, 8, 9)
433+
default_keymap = ('1', '2', '3', '4', '5', '6', '7', '8', '9')
434434

435435
def trigger(self, sender, event, data=None):
436436
mpl.backend_bases.key_press_handler(event, self.figure.canvas, None)

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,15 @@ def _normalize_shortcut(self, key):
824824

825825
return ''.join(mods) + key
826826

827+
def _is_valid_shortcut(self, key):
828+
"""
829+
Check for a valid shortcut to be displayed.
830+
831+
- GTK will never send 'cmd+' (see `FigureCanvasGTK3._get_key`).
832+
- The shortcut window only shows keyboard shortcuts, not mouse buttons.
833+
"""
834+
return 'cmd+' not in key and not key.startswith('MouseButton.')
835+
827836
def _show_shortcuts_window(self):
828837
section = Gtk.ShortcutsSection()
829838

@@ -844,8 +853,7 @@ def _show_shortcuts_window(self):
844853
accelerator=' '.join(
845854
self._normalize_shortcut(key)
846855
for key in self.toolmanager.get_tool_keymap(name)
847-
# Will never be sent:
848-
if 'cmd+' not in key),
856+
if self._is_valid_shortcut(key)),
849857
title=tool.name,
850858
subtitle=tool.description)
851859
group.add(shortcut)

0 commit comments

Comments
 (0)
0