Tk - Treeview Widget


Advertisements

Treeview widget is used to choose a numeric value through sliders. The syntax for treeview widget is shown below.

treeview treeviewName options

Options

The options available for the treeview widget are listed below in table.

Sr.No. Syntax & Description
1

-columns columnNames

An array of column names for widget.

2

-displaycolumns columns

An array of column names or indices specifying columns to be displayed. Use #all for all.

3

-height number

Height for widget.

4

-selectmode mode

Selection mode which can be extended, browse, or none.

A simple example for treeview widget is shown below.

#!/usr/bin/wish

ttk::treeview .tree -columns "Creator Year" -displaycolumns "Year Creator" 
.tree heading Creator -text "Creator" -anchor center
.tree heading Year -text "Year" -anchor center
pack .tree
.tree insert {} end -id Languages -text "Languages"
.tree insert Languages end -text C -values [list "Dennis Ritchie" "1990"]
.tree insert "" end -id Direct -text "Direct"   

When we run the above program, we will get the following output.

Treeview Widget

To move the elements, we can use the following command.

.tree move Languages Direct end

We will get the following output when the above command is executed.

Treeview Widget2

Similarly, we can use the delete command to delete a values from treeview.

tk_mega_widgets.htm
Advertisements