<>Enter Category Here Takes a nested dict, here made with non-existent proc makeNestedDict, and populates a ttk::treeview ====== proc getName path { return [file rootname [file tail $path]] } proc isLeaf item { return [expr {$item == {}}] } proc populateTreeView {tree parent dic} { foreach {k v} $dic { set k [getName $k] if { [isLeaf $v] } { # $parent$k ensures unique id $tree insert $parent end -id $parent$k -text $k } else { # $k$v ensures unique id $tree insert $parent end -id $k$v -text $k populateTreeView $tree $k$v $v } } } proc makeTreeView { } { ttk::treeview .tree .tree configure -columns "items" .tree configure -height 20 .tree column "items" -width 200 -anchor center set nestedDict [makeNestedDict] populateTreeView .tree {} $nestedDict pack .tree } makeTreeView ====== An example of a function which makes a nested dict follows. ====== # builds a flat list of files/directories one level under $path proc ls {path} { return [glob -nocomplain -directory $path *] } # recursively builds a nested dict of all files/directories under $path proc ls-R {path} { set result {} foreach item [ls $path] { if {[file isdirectory [file join $path $item]]} { dict set result $item [ls-R [file join $path $item]] } else { dict set result $item {} } } return $result } # makes the filesystem tree proc makeNestedDict {path} { return [ls-R $path] } makeNestedDict {/var} ======