| PyGTK Tutorial | ||
|---|---|---|
| <<< Previous | Next >>> | |
The Tree widget has its own window, and defaults to a white background, as does CList. Also, most of the Tree methods work in the same way as the corresponding CList ones. However, Tree is not derived from CList, so you cannot use them interchangeably.
tree = GtkTree() |
Like the CList widget, a Tree will simply keep growing as more items are added to it, as well as when subtrees are expanded. For this reason, they are almost always packed into a ScrolledWindow. You might want to use the set_usize() method on the scrolled window to ensure that it is big enough to see the tree's items, as the default size for ScrolledWindow is quite small.
Now that you have a tree,
you'll probably want to add some items to it. The
Tree Item Widget below explains the gory details of TreeItem. For now,
it'll suffice to create one, using:
tree_item = GtkTreeItem(label) |
You can then add it to the tree
using one of the following (see
Methods
below for more options):
tree.append(tree_item) tree.prepend(tree_item) |
Note that you must add items to a Tree one at a time.
| <<< Previous | Home | Next >>> |
| Utilizing row data | Adding a Subtree |