12.2. Adding and Removing nodes

The items in a CTree are termed nodes. Nodes are inserted into a CTree in such a way as to create a hierarchy (although the order of insertion is not critical). The following method is used to insert a node:
node = ctree.insert_node(parent, sibling, text, spacing, pixmap_closed, mask_closed,
                         pixmap_opened, mask_opened, is_leaf, expanded)

This method looks a little daunting, but that is merely due to the power of the CTree widget. Not all of the parameters above are required. The short version is:
node = ctree.insert_node(parent, sibling, text)

The CTree widget allows you to specify pixmaps to display in each node. For branch nodes, you can specify different pixmaps for when the branch is collapsed or expanded. This gives a nice visual feedback to the user, but it is optional so you don't have to specify pixmaps.

Lets have a quick look at all of the parameters:

An object of type GtkCTreeNode is returned by the insert_node() method. This object reference is used to access the node when manipulating it. The node reference is also supplied by many of the CTree signals to identify which node the signal pertains to.

To remove a node for a CTree, the following method is provided:

As you can see, you merely need to specify a CTree and the node to remove.