13.2. Adding a Subtree

A subtree is created like any other Tree widget. A subtree is added to another tree beneath a tree item, using:
 
tree_item.set_subtree(subtree)

You do not need to call the show() method on a subtree before or after adding it to a TreeItem. However, you must have added the TreeItem in question to a parent tree before calling the set_subtree() method. This is because, technically, the parent of the subtree is not the GtkTreeItem which "owns" it, but rather the GtkTree which holds that GtkTreeItem.

When you add a subtree to a TreeItem, a plus or minus sign appears beside it, which the user can click on to "expand" or "collapse" it, meaning, to show or hide its subtree. TreeItems are collapsed by default. Note that when you collapse a TreeItem, any selected items in its subtree remain selected, which may not be what the user expects.