Skip to content
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

No able to receive window close button event #49

Closed
rameshgandhim opened this issue Jun 3, 2015 · 2 comments
Closed

No able to receive window close button event #49

rameshgandhim opened this issue Jun 3, 2015 · 2 comments

Comments

@rameshgandhim
Copy link

For Example :

def on_close():
print ("Closed application")

root = tkinter.Tk()
root.protocol("WM_DELETE_WINDOW", on_close)
app = Application(root)
app.run()

Not sure how to catch window close event.
It will be helpful if anyone can suggest me on this.

(Big thanks for pygubu ☺️ )

@alejandroautalan
Copy link
Owner

Hello rameshgandhim,

To close the window you need to call the destroy method in the toplevel widget.
I have just created a wiki page to show how is done.

https://github.com/alejandroautalan/pygubu/wiki/CapturingDeleteWindowEvent

Thanks for trying pygubu.
Regards.

@rameshgandhim
Copy link
Author

Thanks alejandro!!

It seems like i was doing

if __name__ == '__main__':
    root = tk.Tk()
    app = Application(root)
    app.run()

It works if i change app.run() to root.mainloop() to :

if __name__ == '__main__':
    root = tk.Tk()
    app = Application(root)
    root.mainloop()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants