ttk::treeview selection
Gives or changes the selected items.
PATHNAME selection
PATHNAME selection set|add|remove|toggle ITEMLIST
Description
With no argument, gives the IDs of the selected items in the order of the tree. set selects the items of ITEMLIST and no other item. add selects them too, remove clears them, and toggle changes each one. A change sends <<TreeviewSelect>> as an idle callback.
Returns
A list of IDs, or an empty string.
Examples
% ttk::treeview .ttvsl
> foreach id {a b c} {.ttvsl insert {} end -id $id}
> .ttvsl selection set {c a}
> .ttvsl selection toggle {a b}
> .ttvsl selection
b c
% ttk::treeview .ttvsl2
> .ttvsl2 insert {} end -id a
> update
> bind .ttvsl2 <<TreeviewSelect>> {set ::ttvsel [%W selection]}
> .ttvsl2 selection set a
> update
> set ::ttvsel
a
Errors
% ttk::treeview .ttvsl3; .ttvsl3 selection set nosuch
Item nosuch not found
-errorcode NONE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1