Posted to tcl by nscerqueira at Mon May 27 21:55:59 GMT 2013view raw
- : # Demo code
- #
-
-
- ::ttk::treeview .tree -height 15 -show tree \
- -yscroll ".vsb set" -xscroll ".hsb set" -selectmode browse
- ::ttk::scrollbar .vsb -orient vertical -command ".tree yview"
- ::ttk::scrollbar .hsb -orient horizontal -command ".tree xview"
-
- grid .tree .vsb -sticky nsew
- grid .hsb -sticky nsew
- grid column . 0 -weight 1
- grid row . 1 -weight 1
-
- ## Create Data Set
- foreach txt {first second third} {
- set id [.tree insert {} end -text "$txt item" -open 1]
-
- for {set i [expr {1+int(rand()*5)}]} {$i > 0} {incr i -1} {
- set child [.tree insert $id 0 -text "child $i"]
-
- for {set j [expr {int(rand()*3)}]} {$j > 0} {incr j -1} {
- .tree insert $child 0 -text "grandchild $i"
- }
- }
- }