![Tcl/Tk Tutorial](/tcl-tk/images/tcl-tk-mini-logo.jpg)
- Tcl Tutorial
- Tcl - Home
- Tcl - Overview
- Tcl - Environment Setup
- Tcl - Special Variables
- Tcl - Basic Syntax
- Tcl - Commands
- Tcl - Data Types
- Tcl - Variables
- Tcl - Operators
- Tcl - Decisions
- Tcl - Loops
- Tcl - Arrays
- Tcl - Strings
- Tcl - Lists
- Tcl - Dictionary
- Tcl - Procedures
- Tcl - Packages
- Tcl - Namespaces
- Tcl - File I/O
- Tcl - Error Handling
- Tcl - Built-in Functions
- Tcl - Regular Expressions
- Tk Tutorial
- Tk - Overview
- Tk - Environment
- Tk - Special Variables
- Tk - Widgets Overview
- Tk - Basic Widgets
- Tk - Layout Widgets
- Tk - Selection Widgets
- Tk - Canvas Widgets
- Tk - Mega Widgets
- Tk - Fonts
- Tk - Images
- Tk - Events
- Tk - Windows Manager
- Tk - Geometry Manager
- Tcl/Tk Useful Resources
- Tcl/Tk - Quick Guide
- Tcl/Tk - Useful Resources
- Tcl/Tk - Discussion
Tk - Treeview Widget
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](/tcl-tk/images/treeWidget1.png)
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](/tcl-tk/images/treeWidget2.png)
Similarly, we can use the delete command to delete a values from treeview.