# module tktest.py
import Tkinter
def message (s):
top = Tkinter.Frame(None, {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()
#end module tktest
and did the following:
/import/python/src/Python 941 % python
Python 1.0.2 (Jun 8 1994)
Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam
>>> import tktest
>>> tktest.message('foo')
>>>
(having pressed the OK button), that the "msg" and "accept" widgets
would have been GC'ed upon exit from tktest.message, which their being
the only ones hanging on to "top" would have caused it to be GC'ed,
which would cause the window in which they were all displayed to be
GC'ed and disappear. No such luck.
Bill