CheckboxTreeview

class ttkwidgets.CheckboxTreeview(master=None, **kw)[source]

Bases: ttk.Treeview

ttk.Treeview widget with checkboxes left of each item.

Note

The checkboxes are done via the image attribute of the item, so to keep the checkbox, you cannot add an image to the item.

__init__(master=None, **kw)[source]

Create a CheckboxTreeview.

Parameters:
  • master (widget) – master widget
  • kw – options to be passed on to the ttk.Treeview initializer
change_state(item, state)[source]

Replace the current state of the item.

i.e. replace the current state tag but keeps the other tags.

Parameters:
  • item (str) – item id
  • state (str) – “checked”, “unchecked” or “tristate”: new state of the item
collapse_all()[source]

Collapse all items.

expand_all()[source]

Expand all items.

get_checked()[source]

Return the list of checked items that do not have any child.

insert(parent, index, iid=None, **kw)[source]

Creates a new item and return the item identifier of the newly created item.

Parameters:
  • parent (str) – identifier of the parent item
  • index (int or "end") – where in the list of parent’s children to insert the new item
  • iid (None or str) – item identifier, iid must not already exist in the tree. If iid is None a new unique identifier is generated.
  • kw – other options to be passed on to the ttk.Treeview.insert() method
Returns:

the item identifier of the newly created item

Return type:

str

Note

Same method as for the standard ttk.Treeview but add the tag for the box state accordingly to the parent state if no tag among (‘checked’, ‘unchecked’, ‘tristate’) is given.

state(statespec=None)[source]

Modify or inquire widget state.

Parameters:statespec (None or sequence[str]) – Widget state is returned if statespec is None, otherwise it is set according to the statespec flags and then a new state spec is returned indicating which flags were changed.
tag_add(item, tag)[source]

Add tag to the tags of item.

Parameters:
  • item (str) – item identifier
  • tag (str) – tag name
tag_del(item, tag)[source]

Remove tag from the tags of item.

Parameters:
  • item (str) – item identifier
  • tag (str) – tag name