MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _normalize_shortcut

Method _normalize_shortcut

lib/matplotlib/backends/backend_gtk4.py:544–568  ·  view source on GitHub ↗

Convert Matplotlib key presses to GTK+ accelerator identifiers. Related to `FigureCanvasGTK4._get_key`.

(self, key)

Source from the content-addressed store, hash-verified

542@backend_tools._register_tool_class(FigureCanvasGTK4)
543class HelpGTK4(backend_tools.ToolHelpBase):
544 def _normalize_shortcut(self, key):
545 """
546 Convert Matplotlib key presses to GTK+ accelerator identifiers.
547
548 Related to `FigureCanvasGTK4._get_key`.
549 """
550 special = {
551 'backspace': 'BackSpace',
552 'pagedown': 'Page_Down',
553 'pageup': 'Page_Up',
554 'scroll_lock': 'Scroll_Lock',
555 }
556
557 parts = key.split('+')
558 mods = ['<' + mod + '>' for mod in parts[:-1]]
559 key = parts[-1]
560
561 if key in special:
562 key = special[key]
563 elif len(key) > 1:
564 key = key.capitalize()
565 elif key.isupper():
566 mods += ['<shift>']
567
568 return ''.join(mods) + key
569
570 def _is_valid_shortcut(self, key):
571 """

Callers 1

triggerMethod · 0.95

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected