Next: Tix Object Oriented Up: Selecting Files and Previous: 5.1.5 The tix


Selecting Directories with the TixDirTree and TixDirList Widgets 

There are two Tix widgets for selecting a directory: TixDirList (figure 5-6 ) and TixDirTree (figure 5-6). Both of them display the directories in a hierarchical format. The display in the TixDirList widget is more compact: it shows only the parent- and child-directories of a particular directory. The TixDirTree widget, on the other hand, can display the whole tree structure of the file system.

The programming interface of these two widgets are the same and you can choose the which one to use depending on your application. As shown in the following example, you can use the -directory option of the TixDirList widget to specify a directory to display. In the example, we set -directory to be /home/ioi/dev. As a result, the TixDirList widget displays all the subdirectories and all the ancestor directories of /home/ioi/dev. You can use the -command and -browsecmd options to handle the user events: a double click or Return key-stroke will trigger the -command option and a single click or space bar key stroke will trigger the -browsecmd option. Normally, you would handle both type of events in the same manner, as we have done in program 5-5

tixDirList .d -value /home/ioi/dev
-command "selectDir" -browsecmd "selectDir"
pack .d

proc selectDir {dir} {
puts "now you select $dir"

(Figure 5-5) Using the TixDirList widget 

(Figure 5-6) The DirTree and DirList Widgets