How do I handle the window close event (user clicking the 'X' button) in a Python Tkinter program?
views:
2251answers:
1
+5
Q:
How do I handle the window close event (user clicking the 'X' button) in a Python Tkinter program?
+5
A:
Use a Tkinter protocol handler to handle window manager events:
root.protocol("WM_DELETE_WINDOW", handler)
# or toplevel.protocol(...
def handler():
if tkMessageBox.askokcancel("Quit?", "Are you sure you want to quit?"):
root.quit()
Matt Gregory
2008-09-21 14:51:11