Tkinter & all widgets

Matthew Dixon Cowles matt at
Mon Oct 15 01:39:42 CEST 2001

On Sun, 14 Oct 2001 22:30:08 GMT, David Ashe <dash at> wrote:
>Is there a way to get the complete list of widgets in a window as a
>list, array, dictionary, or tuple?  I seem to recall this was
>possible under tcl, but I can't remember how.

Yes, you can use the children attribute:

>>> from Tkinter import *
>>> r=Tk()
>>> l=Label(r,text="foo")
>>> l.pack()
>>> e=Entry(r)
>>> e.pack()
>>> r.children
{'136255148': <Tkinter.Label instance at 0x81f16ac>,
 '136377364': <Tkinter.Entry instance at 0x820f414>}
>>> r.children.values()
[<Tkinter.Label instance at 0x81f16ac>, <Tkinter.Entry instance at 0x820f414>]
>>> r.children.values()[0].configure(text="bar")


More information about the Python-list mailing list