Title: [Bug]: Event handling with input in callback function · Issue #30419 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Event handling with input in callback function · Issue #30419 · matplotlib/matplotlib
X Title: [Bug]: Event handling with input in callback function · Issue #30419 · matplotlib/matplotlib
Description: Bug summary When using a button click event handler, if the callback function includes the input function, the figure automatically closes when the callback function finishes. Code for reproduction import matplotlib.pyplot as plt import ...
Open Graph Description: Bug summary When using a button click event handler, if the callback function includes the input function, the figure automatically closes when the callback function finishes. Code for reproduction...
X Description: Bug summary When using a button click event handler, if the callback function includes the input function, the figure automatically closes when the callback function finishes. Code for reproduction...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30419
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Event handling with input in callback function","articleBody":"### Bug summary\n\nWhen using a [button click event handler](https://matplotlib.org/stable/users/explain/figure/event_handling.html), if the callback function includes the [input](https://docs.python.org/3/library/functions.html#input) function, the figure automatically closes when the callback function finishes.\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfig, ax = plt.subplots()\nax.plot(np.random.rand(10))\n\ndef onclick(event):\n print(f'click: x={event.x}, y={event.y}')\n info = input('Enter some information about this point: ') # Comment out this line\n print(info) # Comment out this line\n\ncid = fig.canvas.mpl_connect('button_press_event', onclick)\n\nplt.show()\n```\n\n### Actual outcome\n\nAfter a single event and iteration of the `onclick` callback function, the figure automatically closes without giving the user the opportunity to click on more points.\n\nhttps://github.com/user-attachments/assets/58768094-9bce-4320-95ad-2446bb5ff92c\n\n### Expected outcome\n\nThe figure should remain open and allow the user to click on many points until the user explicitly closes it. This is the standard behavior when the two lines indicated in the MWE related to the `input` function are commented out.\n\nhttps://github.com/user-attachments/assets/cf99ca2a-5902-4c6d-a51c-854fbe7da6cc\n\n\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nOS/X\n\n### Matplotlib Version\n\n3.10.3\n\n### Matplotlib Backend\n\nmacosx\n\n### Python version\n\nPython 3.13.5\n\n### Jupyter version\n\n4.4.5\n\n### Installation\n\npip","author":{"url":"https://github.com/ljlamarche","@type":"Person","name":"ljlamarche"},"datePublished":"2025-08-13T00:31:09Z","url":"https://github.com/matplotlib/matplotlib/issues/30419"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5a6e1924-7d38-0b67-7ec6-30721bed8274 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E29E:3B6B85:1931766:213C270:6B067902 |
| html-safe-nonce | 8894a5793e6f090d5d41ab31cb417b06a4c388290d096889d4cb6649a56030ea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjlFOjNCNkI4NToxOTMxNzY2OjIxM0MyNzA6NkIwNjc5MDIiLCJ2aXNpdG9yX2lkIjoiMTcyNTQ1NjI2MzQ2MDMyMTUzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c0ce5e4e32a5535253e54ce90f00379193527bcd70022eae214c33280974975c |
| hovercard-subject-tag | issue:3316491145 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/30419/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eedfd99b6ef25d7a000e0d3685d4fced2d6fa0c617cfff5fc434ae72431ab050/matplotlib/matplotlib/issues/30419 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eedfd99b6ef25d7a000e0d3685d4fced2d6fa0c617cfff5fc434ae72431ab050/matplotlib/matplotlib/issues/30419 |
| og:image:alt | Bug summary When using a button click event handler, if the callback function includes the input function, the figure automatically closes when the callback function finishes. Code for reproduction... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ljlamarche |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4462ff7ebfd3d551f202659f2423dae617b6849d23b1df6465dc504ef497d14a |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6d3909414814ff86ce7da4c51a0f4918a13fb41b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width