Are tk derived objects ever destroyed?

Jerome Quelin jerome.quelin at insalien.org
Sat Jul 1 03:48:12 EDT 2000


"richard_chamberlain" <richard_chamberlain at ntlworld.com> wrote:
>Unless you explicitly call destroy against your class it doesn't seem to
>call ___del__. You can get round it in the following manner:
>#!/usr/bin/python
>from Tkinter import *
>class Frm(Toplevel):
>    def __init__(self):
>        Toplevel.__init__(self)
>        Label(self, text='spam').pack()
>        self.bind('<Destroy>',self.kill)
>    def kill(self,event):
>        self.destroy()
>    def __del__(self):
>        print 'Kai kai kai'
>Button(text='create', command=Frm).pack()
>mainloop()

Well, when I look at this code, I feel like python will start an infinite loop.
But, ok I'll try this. Can you explain why this work this way, and why should
we trap the destroy event?

Regards,
Jerome
--
jerome.quelin at insalien.org




More information about the Python-list mailing list