Tkinter question: WM_DELETE_WINDOW confusion

cz chedz at yahoo.com
Mon Sep 17 17:26:35 EDT 2001


I have a class that does the following:

class A:

  def cleanup(self):
     print "testing...."
     self.window.destroy()

  def __init__(self, master)
     self.window = Toplevel(master)
     self.window.protocol("WM_DELETE_WINDOW", self.cleanup)

Simply initializing an instance of the class and then close (kill) the window
doesn't seem to cause cleanup to execute. However, if i do the following
in the interpreter:

>> v = A(Tkinter.Tk())
>> v.window.protocol("WM_DELETE_WINDOW", v.cleanup)

Then cleanup will be called when i close(kill) the window. 

I don't know why the former didn't work while the later did. I am quite
puzzled by this. I am using python21 on Windows 2000.

Thanks,

--cz



More information about the Python-list mailing list