-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix interrupting GTK on plain Python #21530
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
Conversation
The difference in behavior I can see is that after |
Arg yes, I just forgot the |
When the application is shut down, it's intended that all windows are closed. This shutdown event is also run if interrupted with Ctrl-C. But then the main loop is no longer running, and windows do not notice the close event sent to them. In IPython, the input hook runs the loop and allows the windows to close down. But in plain Python, there is no input hook integration, and the windows sit around in limbo without accepting any events. Absent any new input hook integrations, the workaround is to iterate the main loop on interrupt.
9277681
to
cf659c6
Compare
Then it's not clear to me what this is trying to achieve? (i.e., is there an example that didn't work previously and is fixed by this?) |
You need to be in an interactive shell to see the difference. Previously, interrupting a plain Python shell would return control to the shell but leave the windows in limbo. In IPython, they would be closed because the input hook runs the event loop. |
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.
Ah yes, that works (althought this seems needed only on gtk3, for me, but this seems harmless to have on gtk4 as well).
On a related note, looks like on wxagg+plain python shell, ctrl-c actually quits the entire process; is that something you want to fix as well? |
I did take a look; there is a |
Ah, if that's just defaukt toolkit behavior, I think we should just leave things as they are (perhaps with a note somewhere) and let people configure this as they see fit. |
…530-on-v3.5.x Backport PR #21530 on branch v3.5.x (Fix interrupting GTK on plain Python)
PR Summary
When the application is shut down, it's intended that all windows are closed. This shutdown event is also run if interrupted with Ctrl-C. But then the main loop is no longer running, and windows do not notice the close event sent to them.
In IPython, the input hook runs the loop and allows the windows to close down. But in plain Python, there is no input hook integration, and the windows sit around in limbo without accepting any events.
Absent any new input hook integrations, the workaround is to iterate the main loop on interrupt.
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).