Capture close window button in Tkinter

William Gill noreply at gcgroup.net
Sun Jun 12 11:52:48 EDT 2005


I am trying to make a simple data editor in Tkinter where each data 
element has a corresponding Entry widget.   I have tried to use the 
FocusIn/FocusOut events to set a 'hasChanged' flag  (if a record has not 
changed, the db doesn’t need updating).  This seems to work fine except 
that when the user finishes and clicks a ‘done’ button or the close 
window button (in the root widget) no FocusOut event is triggered.  I 
can trigger a FocusOut event if the ‘done’ button opens another window 
(i.e. a messagebox) that takes focus.  Enter and Leave follow the mouse, 
but don’t trigger when the user tabs between fields.

Is there a better way to monitor 'hasChanged'?   Also, how do I capture 
the root window close button?

Thanks,

Bill



More information about the Python-list mailing list