-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Close all plot windows of a blocking show() on Ctrl+C #27064
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
ac7f86b
to
0c603a6
Compare
test failures definitely seem related? |
0c603a6
to
2c51e34
Compare
Re: test failures The semantics of
is somewhat unclear: What is the qapp parameter?
passes in a QEventLoop
passes in a QApplication @tacaswell @anntzer do you have a fundamental understanding of the I've now "fixed" this PR by checking |
Yes. Really, _maybe_allow_interrupt takes as parameter something on which it can call the |
Thanks for the clarification. My take on this is:
Thus, the |
|
From the docs https://doc.qt.io/qt-6/qcoreapplication.html#quit it looks like it does not actually close all open windows: import sys
from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QPushButton
app = QApplication(sys.argv)
widget = QWidget()
textLabel = QLabel(widget)
textLabel.setText("Hello World!")
textLabel.move(110, 85)
widget.setWindowTitle("PyQt6 Example")
button1 = QPushButton(widget)
button1.setText("Button1")
button1.move(64, 32)
def test():
print("pushed the button!")
app.quit()
print("tried to quit!")
button1.clicked.connect(test)
widget.show()
input("hit enter: ")
In the case of making an EventLoop object you likely do not want to close all of the windows when you quit the loop (as they tend to be used as "sub" event loops). None of this works with PySide because they do not install a input hook. |
#26970 is related in spirit |
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.
2c51e34
to
73c0bd6
Compare
I now use |
Addresses the Qt part of #23385 (comment).
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.