Copyright © 2008, 2009 Arndt Roger Schneider
Table of Contents
A Tree presents information in an hierarchical relationship. There are different ways to implement hierarchies in Tk.
Hierarchy Implementations
As a list, where each »leaf« is indented in relationship to its parent »node«. A Tcl/Tk 'text' window can be used to implement such an hierarchy.
Using a text window is the most easiest way to implement a hierarchy. The restrictions are mainly graphical: Such as no connection lines between nodes, Drag'n'Drop isn’t possible and rubber band selection won’t work either.
As a graph, where the relationship is indicated by indentation and by arrows. The Rtl_tree is an example of such a hierarchy. It uses a Tcl/Tk 'canvas' for implementation.
There are similar hierarchies, many of them written in C or C++, mainly to gain good performance.
As with every Graphical User Interface, performance does not result from using a certain language.
A fast hierarchy window can be implemented with Tk’s canvas when the graphical size of each node is the same. In such a hierarchy implementation only the visible nodes are drawn, while the invisible nodes get drawn on demand –for example: as the result of a scroll operation.
The Rtl_tree does not guess or assume the size of its nodes. All nodes may exceed the allotted height, defined through the »-indenty« property. This requires an implementation were every child node must be drawn whenever the parent node is being expanded.
The Rtl_tree restricts the drawing operations to the modified sections, in order to gain a good performance.
Another, more important aspect, is data acquisition. Collecting data is often an overlooked property in Graphical User Interface design, leading to serious performance problems.
The Rtl_tree allows to delay data acquisition to when a node is opened. There is a bunch of callback commands, which constitute the on-demand acquisition; see Figure 4.7, “Rtl_tree Callback and Font Properties” and also dragfcn.
The Rtl_tree splits the hierarchy into three sections. The section before the change, the section after the change and the section reflecting the change.