The following example builds a simple tree widget:. Double-clicking on the leaf nodes toggles the value of the displayed text between the values “On” and “Off.”
This example is included in the file tree_widget_example.pro in the examples/doc/widgets subdirectory of the IDL distribution. Run this example procedure by entering tree_widget_example at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT tree_widget_example.pro. See Running the Example Code if IDL does not run the program as expected.
As with many of the examples in this section, this one is designed to merely exhibit the features of the tree widget. Most of the useful things you might do with a tree widget take place in the event handling routines for the leaf nodes; whereas in this example clicking on a leaf changes the displayed text value, in a real application more complicated things might take place. Alternately, you might use a tree widget for display purposes only, in which case user interaction would be limited to expanding and collapsing the branches.