# module tktest
import Tkinter
def message (s):
tk = Tkinter.Tk()
top = Tkinter.Frame(tk, {Tkinter.Pack: {'side': 'top'}})
msg = Tkinter.Message(top, {'text': s, 'width': '3i',
Tkinter.Pack: { 'side': 'top', 'expand': 1,
'fill': 'both', 'padx': '3m', 'pady': '3m'}})
accept = Tkinter.Button(top, {'text': 'OK',
'command': lambda w=top: w.tk.quit(),
Tkinter.Pack: {'side': 'left',
'padx': 4, 'pady': 4,
'expand': 'true'}})
top.mainloop()
accept.destroy()
msg.destroy()
top.destroy()
del tk
# end of module tktest
Now I do:
/import/python/src/Python 949 % python
Python 1.0.2 (Jun 8 1994)
Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam
>>> import tktest
>>> tktest.message('foo')
>>> tktest.message('foo')
>>> tktest.message('foo')
>>>
Yes, there are 3 windows lying around on my screen...
Why the explicit "del" of "tk" doesn't do it, I don't see. It should
call Tkinter.Tk.__del__, which should destroy the root. But it doesn't
seem to.
Bill