PDA

View Full Version : [SOLVED] Override Tkinter Close



themusicwave
March 18th, 2008, 01:54 PM
Good morning everyone,

Well I forgot my copy of Programming Python at home today. So I am wondering if some of you could be a reference for me.

All I need to do is override the close event of a TK frame. The problem is I can't remember the name of th event to bind on. Through searching I can't find anything. I wish I knew where some good TK documents where.

So how do I bind to the close event so I can do a proper close?

Also, is there a good TK reference online that I don't know about?

LaRoza
March 18th, 2008, 02:02 PM
Also, is there a good TK reference online that I don't know about?

References and Docs: http://wiki.python.org/moin/TkInter

Events are at the bottom: http://infohost.nmt.edu/tcc/help/pubs/tkinter/

(Don't know the answer, sorry)

themusicwave
March 18th, 2008, 02:08 PM
I guess to clarify, what I want to do is perform a check on the form close event.

Then if the program isn't done I will warn the user and ask if they want to quit.

On something like Java I would just hook into the event for closing.

stevescripts
March 18th, 2008, 04:46 PM
Do your sanity check on WM_DELETE_WINDOW ...

along the lines of:

toplevel.protocol("WM_DELETE_WINDOW", callback)


where callback is your sanity check.

Hope this helps.

Steve

themusicwave
March 18th, 2008, 05:30 PM
Do your sanity check on WM_DELETE_WINDOW ...

along the lines of:

toplevel.protocol("WM_DELETE_WINDOW", callback)


where callback is your sanity check.

Hope this helps.

Steve

That was exactly what I needed. Thanks!