Chapter 12. CTree Widget

Table of Contents
12.1. Creating a CTree
12.2. Adding and Removing nodes
12.3. Setting CTree Attributes
12.4. Utilizing row data
The CTree widget is derived from the CList widget. It is designed to display hierarchically-organised data. The tree is displayed vertically, and branches of the tree can be collapsed and expanded as required by the user.

This section of the tutorial is under development.

12.1. Creating a CTree

A CTree, being derived from CList, can have multiple columns. These columns optionally have titles that are displayed along the top of the CTree widget. Hence there are two functions for creating a new CTree widget:
 
ctree = GtkCTree(columns,  tree_column, titles)

ctree = GtkCTree(columns,  tree_column)

The columns argument specifies the number of columns that the CTree will contain. The tree_column argument specifies which of those columns is to contain the tree. Columns are numbered starting from 0.

With the first function above, the titles argument contains a list of strings that contain the captions for the column headings. A typical code fragment using the GtkCTree() function would be:
 
    # CTree column titles
    titles = [ "Location" , "Description" ]
 
    ctree = GtkCTree(2, 0, titles)

This would create a new CTree with two columns entitled "Location" and "Description", with the first column containing the tree.