wm title . "Hierarchy Example" ## ## Initialize some data ## set nodes(start) [list a_node b_node c_node d_node e_node] set nodes(a_node) [list a1 a2 a3 a4] set nodes(b_node) [list b1 b2 b3 b4] set nodes(c_node) [list c1 c2 c3 c4] set nodes(d_node) [list d1 d2 d3 d4] set nodes(e_node) [list e1 e2 e3 e4] image create photo rb -file redball.gif image create photo gb -file greenball.gif image create photo tcl -file tcl_logo_small.gif ## ## Supporting procedure for the ## -querycommand option ## proc show {n} { global nodes expr {($n == "") ? [set N start] : [set N $n]} if ![info exists nodes($N)] { return } return $nodes($N) }; # end proc show ##========================================================= ## Create a Hierarchy iwidget ##========================================================= ## iwidgets::hierarchy .h \ -querycommand {show %n} \ -visibleitems 25x14 \ -labeltext "Hierarchy Example" \ -markbackground gray \ -selectbackground yellow \ -closedicon rb \ -openicon gb \ -nodeicon tcl \ -textbackground white pack .h \ -fill both \ -expand true ## ## Need to do this so the following methods ## act after everything has been drawn ## update idletasks ## ## Expand, mark, and select ## some of the nodes ## .h expand b_node .h selection add a_node .h mark add e_node