Description
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.