A [Ttk] [widget] that provides both [tree]-browsing capabilities and multicolumn [listbox] capabilities. http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_treeview.htm More information on the wiki page [treeview]. ---- The screenshot below shows the treeview as part of a larger program (using the ''clam'' theme). There is a header and 6 entries (where two are one level down). [http://tcl.typoscriptics.de/misc/tile-treeview.png] ---- The basics of this widget are: ====== package require tile tile::setTheme clam # create it: ttk::treeview .tree pack .tree -expand 1 -fill both # insert an entry at the root level: set entry1 [.tree insert {} end -text "first item"] # and a second one: set entry2 [.tree insert {} end -text "second item"] # insert a new level with entry1 as parent: .tree insert $entry1 end -text "a sublevel" # insert another item under this one: .tree insert $entry1 end -text "another item" # suppose, one item is selected. # we can then delete it thus: .tree delete [.tree selection] ====== ---- [BAS] ====== # Also, to add the heading: .tree heading #0 -text Features # I also like the heading a little closer to the frame .tree configure -padding {0 0 0 0} ====== ---- [SLB] For an example of how to implement sorting in treeview see [Tile Table] ---- [MHo] 2008-04-09: Does someone know why a horizontal [scrollbar] does not work properly in conjunction with this widget? It seems that the hsb never gets updated. <
> [D. McC] 2008-04-12: Have you specified minimum column widths with the '''-minwidth''' option? I used to have this problem too, and it went away when I specified minimum widths. <
> [MHo]: No, haven't tried yet. Switched the whole GUI of my app to [BWidget]s because I had other problems with [tile], too. [MHo] 09-nov-2008: With '''-stretch 1''', the scrollbar is missing, with '''-stretch 0''', it's there! <
> [Luis Calvo] 2008-11-28: Hi! I have detected the same "bug" even with '''-minwidth''' option at columns. You can find the bug in the 8.5.5 tcl demo: If you take the tcl multi-column list of countries sample and you increase a width column, the x-scroll is working but you can not select or resize the new area. Thanks anyway! ---- [JH] I found the old-school border style of treeview on xpnative to be unsatisfactory. Pat pointed out this helpful alternative layout: ====== ttk::style layout Treeview { Entry.field -sticky news -border 2 -children { Treeview.padding -sticky news -children { Treeview.treearea -sticky news } } } ====== You can remove the Entry.field outer part to have purely no border as well. This is good when wrapping it in something like widget::scrolledwindow. ---- [ofv] 2009-05-30: I've looked at ttk::treeview source and it seems that one key requirement was completely overlooked: when a node is expanded, the column holding the tree may need to expand for accommodating the new visible items, reflecting the width change on the associated horizontal scrollbar (if any). Right now the code handles the tree as a fixed-width column, much on the way a listbox does. This problem appears on different instances, even if you get the horizontal scrollbar to work with the '''-minwidth''' trick. It is not possible to select a node by clicking on it when it is too nested so that it is drawn to the right of the initial visible area. When you have several columns, the tree items are partially drawn over the adyacent columns if there is no space on the tree's column, etc. See the bugs on the SF project page for details. I don't recommend using ttk::treeview unless you know in advance that the tree items will not require more horizontal space than the assigned column width. ---- '''[snehanish] - 2010-05-27 04:25:40''' in tree mode ( -show tree) is it not possible to put index number in integer foam. i mean first column in tree mode always give row numbers. whenever we delete an item the row number should be updated. for example lets have height of treeview is 10, so we have 10 rows , column 0 indicate 1 to 10 in integer. if i delete item 5 then it should update all index numbers. if you could add this feature then it would be great. Thanks '''[hae] 2010-05-27''' If you want this feature, then put it into the http://sourceforge.net/tracker/?group_id=12997&atid=362997%|%Tcl feature request tracker%|% <> Widget