Are tk derived objects ever destroyed?

Jerome Quelin jerome.quelin at insalien.org
Fri Jun 30 06:15:49 EDT 2000


Hi all,

Look at the snippet code below:

-- File toplevel_creator.py
#!/usr/bin/python
from Tkinter import *
class Frm(Toplevel):
    def __init__(self):
        Toplevel.__init__(self)
        Label(self, text='spam').pack()
    def __del__(self):
        print 'Kai kai kai'
Button(text='create', command=Frm).pack()
mainloop()
-- End of file

When running this code and creating some toplevel windows with the
create button, the objects aren't destroyed (the __del__ function
doesn't get called) when I destroy the window.
I wonder why, since there aren't any other references to this toplevel
window. Unless Tkinter keeps tracks of all widgets created? Or
destroying the widgets does not clears all references to the widget?
Then what must I do to destroy the object when the window gets
destroyed?

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




More information about the Python-list mailing list