29

Is it possible to get all of the children of a Tkinter widget, then get the children's children etc.?

Basically I want all of the widgets within one entire window.

Edit : I found a solution utilizing Bryan's line :

def all_children (wid) :
    _list = wid.winfo_children()

    for item in _list :
        if item.winfo_children() :
            _list.extend(item.winfo_children())

    return _list
Sam
  • 1,501
  • 3
  • 19
  • 28
rectangletangle
  • 46,943
  • 90
  • 196
  • 270
  • For searchers (such as myself) the key word is "recursively", eg "How do I recursively iterate over all children of a widget." – tex Nov 01 '15 at 14:04

1 Answers1

33

The method you are looking for is winfo_children.

Bryan Oakley
  • 341,422
  • 46
  • 489
  • 636
  • 1
    Bryan's link no longer is active try this one instead [Every Child](https://www.tutorialspoint.com/getting-every-child-widget-of-a-tkinter-window) – Jim Robinson Dec 09 '21 at 04:54