Clearing the Tkinter Window

Fredrik Lundh fredrik at pythonware.com
Fri Dec 16 09:01:57 EST 2005


"Dustan" <DustanGroups at gmail.com> wrote:

>I don't want to destroy the root, I just want to remove the widgets
> (the exact opposite of what Martin was saying).  I started working on
> James' idea, but it'll be a while before I have it fully implemented to
> test.

each widget has a "children" attribute, which contains a dictionary with Tk widget
names as keys, and Python widget objects as values.  to destroy all child widgets,
you can simply do:

    for w in widget.children.values():
        w.destroy()

where "widget" is the widget you want to reset.

</F> 






More information about the Python-list mailing list