pyface.viewer.tree_item module

A generic base-class for items in a tree data structure.

An example:

root = TreeItem(data='Root')

fruit = TreeItem(data='Fruit')
fruit.append(TreeItem(data='Apple', allows_children=False))
fruit.append(TreeItem(data='Orange', allows_children=False))
fruit.append(TreeItem(data='Pear', allows_children=False))
root.append(fruit)

veg = TreeItem(data='Veg')
veg.append(TreeItem(data='Carrot', allows_children=False))
veg.append(TreeItem(data='Cauliflower', allows_children=False))
veg.append(TreeItem(data='Sprout', allows_children=False))
root.append(veg)
class pyface.viewer.tree_item.TreeItem[source]

Bases: HasTraits

A generic base-class for items in a tree data structure.

append(child)[source]

Appends a child to this item.

This removes the child from its current parent (if it has one).

insert(index, child)[source]

Inserts a child into this item at the specified index.

This removes the child from its current parent (if it has one).

remove(child)[source]

Removes a child from this item.

insert_before(before, child)[source]

Inserts a child into this item before the specified item.

This removes the child from its current parent (if it has one).

insert_after(after, child)[source]

Inserts a child into this item after the specified item.

This removes the child from its current parent (if it has one).