Here's a tip to help new Tkinter programmers avoid the trouble I had because
of an error in Grayson's book Python and Tkinter Programming published by
Manning.   On page 309, the protocol methods are briefly explained, with an
example:
self.root.protocol(WM_DELETE_WINDOW, self.cleanup)

This does not work.   There is no error correction in the errata page on the
Manning site for the book.  I finally figured out that WM_DELETE_WINDOW is
not a pre-defined constant like TOP, but rather should be a string in
quotes.   The correct way to invoke the protocol to intercept toplevel
window closing is:
self.root.protocol("WM_DELETE_WINDOW", self.cleanup)

I wrote to Manning to have them add this to their errata, but just in case
they don't do it, I wanted to post this correction note here for others to
find.
-- 
View this message in context: 
http://www.nabble.com/WM_DELETE_WINDOW----the-correct-syntax-to-use-it.-tp16074408p16074408.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to