Title: Warn when trying to start a GUI event loop out of the main thread. by anntzer · Pull Request #15504 · matplotlib/matplotlib · GitHub
Open Graph Title: Warn when trying to start a GUI event loop out of the main thread. by anntzer · Pull Request #15504 · matplotlib/matplotlib
X Title: Warn when trying to start a GUI event loop out of the main thread. by anntzer · Pull Request #15504 · matplotlib/matplotlib
Description: PR Summary The first commit rearchitects a bit pyplot to make it possible to further wrap the backend-provided new_figure_manager(). The second commit uses that to emit a warning when new_figure_manager() (and thus figure()) is called for an GUI backend when not in the main loop. Note that the text of the warning is a placeholder, suggestions for the wording would be welcome. Closes #12085, closes #14304. For the record the main thread requirement is documented at https://developer.gnome.org/gdk3/stable/gdk3-Threads.html https://doc.qt.io/qt-5/thread-basics.html#gui-thread-and-worker-thread http://effbot.org/zone/tkinter-threads.htm https://docs.wxwidgets.org/3.0/overview_thread.html#overview_thread_notes I chose to only emit a warning because 1) it looks like things actually work with gtk if you are extra careful? ("You should only use GTK+ and GDK from the thread gtk_init() and gtk_main() were called on. This is usually referred to as the “main thread”." -- I guess the "gtk main thread" is not necessarily the python main thread, and indeed things don't appear to crash immediately.), and 2) if things are going to crash anyways you'll have a traceback and it's not as if catching the exception would really help, as it's a program logic error. Test e.g. with from threading import Thread from matplotlib.pyplot import show Thread(target=lambda: show()).start() PR Checklist Has Pytest style unit tests Code is Flake 8 compliant New features are documented, with examples if plot related Documentation is sphinx and numpydoc compliant Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there) Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way
Open Graph Description: PR Summary The first commit rearchitects a bit pyplot to make it possible to further wrap the backend-provided new_figure_manager(). The second commit uses that to emit a warning when new_figure_ma...
X Description: PR Summary The first commit rearchitects a bit pyplot to make it possible to further wrap the backend-provided new_figure_manager(). The second commit uses that to emit a warning when new_figure_ma...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/15504
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:aa20b033-4fd4-f1fc-7a2e-ba28af624759 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 82A4:1A7CA7:D36F8A:118557A:6A5327BA |
| html-safe-nonce | 9266c162e62ee3159f7b00f84abfa151e6b8ff1fa1952952f722d1f7df66766f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkE0OjFBN0NBNzpEMzZGOEE6MTE4NTU3QTo2QTUzMjdCQSIsInZpc2l0b3JfaWQiOiIzNTEyMDgxNjQ2OTExNDMyNjM0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e88377f03dfecb0ca4ee2a4149b5e7606fd4b47113cffca77cf4d514f79c4bc7 |
| hovercard-subject-tag | pull_request:332216209 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/matplotlib/matplotlib/pull/15504/files |
| twitter:image | https://avatars.githubusercontent.com/u/1322974?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1322974?s=400&v=4 |
| og:image:alt | PR Summary The first commit rearchitects a bit pyplot to make it possible to further wrap the backend-provided new_figure_manager(). The second commit uses that to emit a warning when new_figure_ma... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width