Tkinter question: WM_DELETE_WINDOW confusion

Matthew Dixon Cowles matt at mondoinfo.com
Mon Sep 17 19:13:15 EDT 2001


On 17 Sep 2001 14:26:35 -0700, cz <chedz at yahoo.com> wrote:

>I have a class that does the following:

>     self.window = Toplevel(master)

>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:

>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.

Hm. It works fine for me (under Linux) as long as I click to close the
correct window. Perhaps the version of Tk that runs under Windows is
getting confused by the fact that you're calling Toplevel() with a
master widget argument. It doesn't need one (though it doesn't
complain under Linux either).

When I run your code with from Tkinter import * above and

def main():
  root=Tk()
  A(root)
  root.mainloop()

if __name__=="__main__":
  main()

below, I get two windows. One that Tkinter opens for free and the
second one as a result of the Toplevel() call. If I close one, the
program exits and if I close the other, I get "testing....".

Regards,
Matt



More information about the Python-list mailing list