Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
DOC: Explain how to start the mainloop after show(block=False)#29742
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
that the event loop is running to have responsive figures; in the | ||
simplest form by calling ``fig.canvas.manager.mainloop()`` which is | ||
what a blocking show is doing internally. Note that the GUI mainloop | ||
itself is blocking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
thattheeventloopisrunningtohaveresponsivefigures;inthe | |
simplestformbycalling``fig.canvas.manager.mainloop()``whichis | |
whatablockingshowisdoinginternally.NotethattheGUImainloop | |
itselfisblocking. | |
thattheeventloopisrunningtohaveresponsivefigures.Calling``fig.canvas.manager.mainloop()`` | |
willworkforthesimplecasebecausethatiswhatablockingshowisdoinginternally.NotethattheGUImainloopisitselfblocking. |
I think I'm getting tripped up by what simplest form is supposed to mean here
This was vague to avoid having to talk about prompt's inputhooks as well. |
The current statement is a bit thin:
I guess only a tiny fraction of our users know what the event loop is, and even fewer whether they have to start it and if so how. I know that the answer is a bit more complex, but I think we can give more guidance. Background: I was asked how to do this if one has N figures (in a simple script), each shown with |
A loop where you create / show figures, call |
Is there a longer guide to this somewhere we can link out to? |
Not that I'm aware of. To collect use cases for
|
I guess this is somewhat discussed athttps://matplotlib.org/stable/users/explain/figure/interactive.html, andhttps://matplotlib.org/stable/users/explain/figure/interactive_guide.html and in particularhttps://matplotlib.org/stable/users/explain/figure/interactive_guide.html#blocking-the-prompt So maybe just linking that here would help? |
timhoffm commentedMar 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Semi-OT: maybe we have to rewrite/reframe the "interactive" docs at some time
|
For sure those docs are very dated. But they do explain blocking etc so linking them would be of some value in my opinion. |
Xref:#28722 |
tacaswell commentedMar 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The first three bullet points should be grouped into one: you want windows to pop up and update while some other (slow) loop is running. e.g.
Add as much complexity of only updating the plot ever N, having multiple figures, passing in a callback, ..., but I think that is the minimal pseudo-code. |
timhoffm commentedMar 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
While they rely on the same underlying technology, these are quite different from a user perspective - which is what counts for our user docs. Being able to resize your window and expecting that the content adapts, is a natural expectation for GUIs and no user would regard this explicitly as "interactive" (conversely not responding to are window resize would be considered "broken"). That's quite different from "I can zoom into the data", and again quite different from "I can write callbacks to respond to user actions". |
Side-topic spinning of frommatplotlib#29742.- Move the paragraph on "GUI events" to it's own section and before "Event loops". It's related but not directly needed for the event loop discussion. It was an odd side topic in the old location between "Event loops" and "Command prompt integration".- Rephrase the section on "Blocking the prompt" and some other smaller wording improvementsNote: There will be a follow-up onmatplotlib#29742, but I think it's best tokeep these unrelated changes separate and get them out of the way beforereworkingmatplotlib#29742.
* DOC: Improve interactive figures guide / Blocking inputSide-topic spinning of from#29742.- Move the paragraph on "GUI events" to it's own section and before "Event loops". It's related but not directly needed for the event loop discussion. It was an odd side topic in the old location between "Event loops" and "Command prompt integration".- Rephrase the section on "Blocking the prompt" and some other smaller wording improvementsNote: There will be a follow-up on#29742, but I think it's best tokeep these unrelated changes separate and get them out of the way beforereworking#29742.* Update galleries/users_explain/figure/interactive_guide.rstCo-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>---------Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
No description provided.