Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting every child widget of a Tkinter window

Tags:

python

tkinter

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
like image 534
rectangletangle Avatar asked Sep 02 '11 23:09

rectangletangle


People also ask

How many widgets are there in Tkinter?

Ttk Widgets Ttk comes with 18 widgets, twelve of which already existed in tkinter: Button , Checkbutton , Entry , Frame , Label , LabelFrame , Menubutton , PanedWindow , Radiobutton , Scale , Scrollbar , and Spinbox . The other six are new: Combobox , Notebook , Progressbar , Separator , Sizegrip and Treeview .

What does Focus_set () do in Tkinter?

Sometimes, we need to change or modify the focus of any widget in the application which can be achieved by using the focus_set() method. This method sets the default focus for any widget and makes it active till the execution of the program.

What does pack () do in Tkinter?

The pack() fill option is used to make a widget fill the entire frame. The pack() expand option is used to expand the widget if the user expands the frame.


1 Answers

The method you are looking for is winfo_children.

like image 147
Bryan Oakley Avatar answered Oct 11 '22 20:10

Bryan Oakley