-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: Ctrl+C on a blocking show() should close the figure window #23385
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
Comments
It should already do that. If you're seeing alternate behaviour, that's backend specific, so you should specify. |
Observed in IPython + Qt |
On |
The figure window stays open in REPL with the tkinter backend too |
Tested on
|
Addresses the Qt part of matplotlib#23385. It appears that `qapp.quit()` does not automatically close the windows of the app. We therefore do it explicitly. A unit test for this would be quite complex. Test this by hand by Ctrl+C in an interactive shell.
Addresses the Qt part of matplotlib#23385. It appears that `qapp.quit()` does not automatically close the windows of the app. We therefore do it explicitly. A unit test for this would be quite complex. Test this by hand by Ctrl+C in an interactive shell.
Note on tkagg: I've tried to add
at matplotlib/lib/matplotlib/backends/_backend_tk.py Lines 522 to 525 in 6501209
and that indeed closes the window. But when trying to show the next figure, I get a stack trace
It seems that Tk is not creating a new application for every plot. But I'm too little of a Tk expert to find out how to do this properly. Ping @daniilS do you know how to handle this? |
I think the issue is that just calling matplotlib/lib/matplotlib/backends/_backend_tk.py Lines 551 to 553 in 6501209
|
Addresses the Qt part of matplotlib#23385. It appears that `qapp.quit()` does not automatically close the windows of the app. We therefore do it explicitly. A unit test for this would be quite complex. Test this by hand by Ctrl+C in an interactive shell.
We should try to avoid injecting matplotlib/mpl-gui#8 is an idea we probably have to implement in Matplotlib core (independent of what we do with mpl-gui) in that we need to add the ability to |
Addresses the Qt part of matplotlib#23385. It appears that `qapp.quit()` does not automatically close the windows of the app. We therefore do it explicitly. A unit test for this would be quite complex. Test this by hand by Ctrl+C in an interactive shell.
@timhoffm re:
Were you testing with qt5 or qt6? I just noted https://doc.qt.io/qt-6/qtcore-changes-qt6.html#other-classes:
Perhaps(?) we may be able to simplify #27064 by just always calling exit() instead of quit()? (both also exist for QEventLoop) |
I don't remember which Qt version I tested with. But as I read this, quit and exit are equivalent for Qt 5 and don't close windows there. So as long as we support Qt5, we still need to handle window closing ourselves. Furthermore in Qt6 quit() was changed to close the windows. So I suppose the Qt6-only simplification would be to drop window closing, but continue to use quit()? |
Problem
Currently,
Ctrl+C
terminates theshow()
call, but the window stays visible.Proposed solution
No response
The text was updated successfully, but these errors were encountered: