Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
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 herehttps://matplotlib.org/stable/gallery/event_handling/keypress_demo.html, but add
importmatplotlibmatplotlib.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:
defon_press(event):event.guiEvent.Skip(False) ...
The reason for this is in this callback handler inbackend_wx.py
def_onKeyDown(self,event):"""Capture key press."""key=self._get_key(event)FigureCanvasBase.key_press_event(self,key,guiEvent=event)ifself:event.Skip()
Since the method ends withevent.Skip()
(same asevent.Skip(True)
) the call toevent.guiEvent.Skip(False)
is ignored.
If this is rewritten as:
def_onKeyDown(self,event):"""Capture key press."""ifself: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.