Next: Creating Entries in Up: TixHList - The Previous: TixHList - The

### Creating a Hierarchical List

A TixHList widget can be created by the command `tixHList`. However, most likely, you would want to create a TixHList with scrollbars attached. Therefore, usually you will use the `tixScrolledHList` command to create a scrolled hierarchical listbox (line 1 in program 4-2). The `tixScrolledHList` command is very similar to the `TixScrolledListBox` command we saw in section 2.3.1. It creates a TixHList subwidget of the name `hlist` and attaches two scrollbars to it.

As shown in the first five lines in program 4-2, we create a scrolled TixHList widget, using the `-options` switch (see section 1.3.5) to set several options for the `hlist` subwidget (we'll talk about these options shortly). Then, we can access the HList subwidget widget using the `subwidget hlist` method (line 7 in program 4-2).

> `tixScrolledHList .sh -options {
> hlist.itemType text
> hlist.drawBranch false
> hlist.indent 8
> }
> pack .sh -expand yes -fill both
> set hlist [.sh subwidget hlist]
> $hlist add foo -text "foo"
> $hlist add foo.bar -text "foo's 1st son"
> $hlist add foo.bor -text "foo's 2nd son"
> $hlist add foo.bar.bao -text "foo's 1st son's 1st son"
> $hlist add foo.bar.kao -text "foo's 1st son's 2nd son"
> $hlist add dor -text "dor, who has no son"`

(Figure 4-2) Creating Entries in a HList Widget