Skip to content
Discussion options

You must be logged in to vote

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?

Yes, you'll need to hook the destroy signal of your window to the Application.quit() method, you can access the application instance through the Window.application property, here's an example...

# ...
app = Application(
    "my-app",
    WaylandWindow(
        # ...
        on_destroy=lambda w, *_: w.application.quit()
    )
)
app.run()

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by SherLock707
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants