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

keypress events cause unavoidable beep sound with wxagg #19658

Copy link
Copy link
Open
@briantoby

Description

@briantoby
Issue body actions

Bug report

Bug summary

Pressing a key in a MPL plot causes a beep. This is not a serious problem, but is annoying.

Code for reproduction

use the code here https://matplotlib.org/stable/gallery/event_handling/keypress_demo.html, but add

import matplotlib
matplotlib.use('wxAgg')

Actual outcome

Every time a key is pressed, I hear a bell sound (a beep).

Expected outcome

I should be able to eliminate this using this in the callback:

def on_press(event):
    event.guiEvent.Skip(False)
    ...

The reason for this is in this callback handler in backend_wx.py

    def _onKeyDown(self, event):
        """Capture key press."""
        key = self._get_key(event)
        FigureCanvasBase.key_press_event(self, key, guiEvent=event)
        if self:
            event.Skip()

Since the method ends with event.Skip() (same as event.Skip(True)) the call to event.guiEvent.Skip(False) is ignored.
If this is rewritten as:

    def _onKeyDown(self, event):
        """Capture key press."""
        if self:
            event.Skip()
        key = self._get_key(event)
        FigureCanvasBase.key_press_event(self, key, guiEvent=event)

Then existing code will function as before, but there is the option to suppress the beep. One could argue that .Skip(False) should be the default, but that would be a change in how MPL functions.

Matplotlib version

  • Operating system: MacOS 10.15.7
  • Matplotlib version: 3.3.2
  • Matplotlib backend: MacOSX
  • Python version: 3.9.1
  • Jupyter version: N/A
  • Other libraries: wxpython 4.1.1

default conda channels except wxpython from pypi.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GUI: wxkeepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.