-
-
Notifications
You must be signed in to change notification settings - Fork 7.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 our terms of service and privacy 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.
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. | |
that the event loop is running to have responsive figures. Calling ``fig.canvas.manager.mainloop()`` | |
will work for the simple case because that is what a blocking show is doing internally. Note that the GUI mainloop is itself blocking. |
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 at https://matplotlib.org/stable/users/explain/figure/interactive.html, and https://matplotlib.org/stable/users/explain/figure/interactive_guide.html and in particular https://matplotlib.org/stable/users/explain/figure/interactive_guide.html#blocking-the-prompt So maybe just linking that here would help? |
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 |
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. |
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 from matplotlib#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 improvements Note: There will be a follow-up on matplotlib#29742, but I think it's best to keep these unrelated changes separate and get them out of the way before reworking matplotlib#29742.
* DOC: Improve interactive figures guide / Blocking input Side-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 improvements Note: There will be a follow-up on #29742, but I think it's best to keep these unrelated changes separate and get them out of the way before reworking #29742. * Update galleries/users_explain/figure/interactive_guide.rst Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com> --------- Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
No description provided.