How can I ensure the event loop exits when the application window is closed? #100
-
I'm running a widget using:
The issue is that when I close the widget window, the event loop remains active and doesn't exit automatically. Here's the terminal output for reference:
Right now, I have to manually interrupt it with Ctrl+C. Is there a clean way to have the event loop terminate as soon as the main window is closed? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Yes, you'll need to hook the # ...
app = Application(
"my-app",
WaylandWindow(
# ...
on_destroy=lambda w, *_: w.application.quit()
)
)
app.run() |
Beta Was this translation helpful? Give feedback.
-
Thanks, seems like this should work, but two weird things:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Nevermind, I can you regular window instead of WaylandWindow. Not sure if this means regular window runs in Xwayland or something. |
Beta Was this translation helpful? Give feedback.
Yes, you'll need to hook the
destroy
signal of your window to theApplication.quit()
method, you can access the application instance through theWindow.application
property, here's an example...