Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key_press_event not working with matplotlib 3.10 #575

Open
peter-urban opened this issue Dec 20, 2024 · 0 comments
Open

key_press_event not working with matplotlib 3.10 #575

peter-urban opened this issue Dec 20, 2024 · 0 comments

Comments

@peter-urban
Copy link

peter-urban commented Dec 20, 2024

Describe the issue

fig.canvas.mpl_connect('key_press_event', ...) does not work anymore with matplotlib 3.10. I compiled the following example to demonstrate this (run in a jupyter notebook):

%matplotlib widget
import matplotlib.pyplot as plt
import matplotlib

from ipywidgets import Output
from IPython.display import display

plt.close('test')
fig,ax = plt.subplots(num='test')

output = Output()
def event_handler(event):
    with output:
        print(event)

fig.canvas.mpl_connect('key_press_event', event_handler)
fig.canvas.mpl_connect('button_release_event', event_handler)

display(output)

When using matplotlib 3.9 the key press event and the mouse button release event cause the event_handler to print the event to the output. After upgrading to matplotlib 3.10, the button_release_event continues to work, but the key_press event does not produce any output anymore. When changing the matplotlib backend to qt (linemagic: "%matplotlib qt") the events work both for matplotlib 3.9 and 3.10

Versions

 3.12.8 | packaged by conda-forge | (main, Dec  5 2024, 14:24:40) [GCC 13.3.0]
ipympl version: 0.9.5
Selected Jupyter core packages...
IPython          : 8.30.0
ipykernel        : 6.29.5
ipywidgets       : 8.1.5
jupyter_client   : 8.6.3
jupyter_core     : 5.7.2
jupyter_server   : 2.14.2
jupyterlab       : 4.3.4
nbclient         : 0.6.8
nbconvert        : 7.16.4
nbformat         : 5.10.4
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.14.3
Known nbextensions:
  config dir: /etc/jupyter/nbconfig
    notebook section
      jupyter-js-widgets/extension  enabled 
      - Validating: problems found:
        - require?  X jupyter-js-widgets/extension
JupyterLab v4.3.4
/ssd/opt/miniforge3/envs/dev/share/jupyter/labextensions
        jupyter-matplotlib v0.11.5 enabled OK
        jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments)
        jupyter-leaflet v0.19.2 enabled OK
        jupyterlab-execute-time v3.2.0 enabled OK (python, jupyterlab_execute_time)
        @jupyter-widgets/jupyterlab-manager v5.0.13 enabled OK (python, jupyterlab_widgets)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant