ttk::treeview(n) Tk Themed Widget ttk::treeview(n)

```

```

# [NAME](#NAME)

ttk::treeview - hierarchical multicolumn data display widget

# [SYNOPSIS](#SYNOPSIS)

**ttk::treeview pathname** ?*options*?

```

```

# [DESCRIPTION](#DESCRIPTION)

The **ttk::treeview** widget displays a hierarchical collection of items. Each item has a textual label, an optional image, and an optional list of data values. The data values are displayed in successive columns after the tree label as cells. The order in which data values are displayed may be controlled by setting the **-displaycolumns** widget option. The tree widget can also display column headings. Columns may be accessed by number or by symbolic names listed in the **-columns** widget option; see **COLUMN IDENTIFIERS**. Treeview widgets support horizontal and vertical scrolling with the standard **-**\[**xy**]**scrollcommand** options and \[**xy**]**view** widget commands.

Each item is identified by a unique name. The widget will generate item IDs if they are not supplied by the caller. There is a distinguished root item, named **{}**. The root item itself is not displayed; only its children appear at the top level of the hierarchy. Cell ids are a 2-value list consisting of the item id and column id. Items and cells may also be associated with 0 or more tags. Tags are used to associate event bindings with individual items/cells and to control their appearance. Items and cells can be selected depending on the **-selectmode** and **-selecttype** widget options. The item and cell focus determines which item or cell receives the keyboard focus for navigation between items and cells and for selection changes.

# [STANDARD OPTIONS](#STANDARD_OPTIONS)

```
-class	-cursor	-takefocus
-style	-xscrollcommand	-yscrollcommand
-padding
```

See the **ttk\_widget** manual entry for details on the standard options.

# [WIDGET-SPECIFIC OPTIONS](#WIDGET-SPECIFIC_OPTIONS)

```
Command-Line Name:	-columns
Database Name:	columns
Database Class:	Columns
```

A list of column identifiers, specifying the number of columns and their names.

```
Command-Line Name:	-displaycolumns
Database Name:	displayColumns
Database Class:	DisplayColumns
```

A list of column identifiers (either symbolic names or integer indices) specifying which columns are to be displayed and the order in which they appear, or the string **#all** to display all columns in **-columns** order. The default is **#all**.

```
Command-Line Name:	-headingheight
Database Name:	headingHeight
Database Class:	Height
```

Specifies the heading height in pixels. The default value is auto calculated based on the theme and font. It can be overridden by this option until the next theme or font change. It can be permanently overridden via ttk::style option: **ttk::style configure Treeview -headingheight pixels**.

```
Command-Line Name:	-height
Database Name:	height
Database Class:	Height
```

Specifies the number of rows which should be visible. Note that the requested width is determined from the sum of the column widths.

```
Command-Line Name:	-rowheight
Database Name:	rowHeight
Database Class:	Height
```

Specifies the row height in pixels. The default value is auto calculated based on the theme and font. It can be overridden by this option until the next theme or font change. It can be permanently overridden via ttk::style option: **ttk::style configure Treeview -rowheight pixels**.

```
Command-Line Name:	-selectmode
Database Name:	selectMode
Database Class:	SelectMode
```

Controls how the built-in class bindings manage the selection. Options are:

[**none**](#none)

The selection cannot be changed. Focus and item/cell navigation is still allowed.

[**browse**](#browse)

Only one item or cell will be selected at a time. Items and cells are selected via Button-1 press. Selecting an item/cell deselects all other items/cells. The selection follows the mouse when Button 1 is kept pressed. The selection follows the focus during keyboard traversal. In this mode, the selection cannot be removed via the keyboard bindings.

[**single**](#single)

Only a single item or cell can be selected at a time. Items and cells are selected via Button-1 press. Selecting an item/cell deselects all other items/cells. The selection follows the focus during keyboard traversal. The selection can be cleared via the keyboard bindings.

[**multiple**](#multiple)

Multiple items or cells can be selected. The selection state of items and cells is toggled via a Button-1 press. Selecting an item/cell does not change the selection state of other items/cells. In this mode, the focus and selection are independent which allows for keyboard traversal to change the focus without changing the selection. The selection can be cleared via the keyboard bindings.

[**extended**](#extended)

Multiple items or cells can be selected, but the default is for only one item/cell to be selected at a time. More items can be selected by extending the selection using the Shift and Control/Command keys in combination with Button 1 press or keyboard traversal. The selection follows the focus during keyboard traversal. The selection can be cleared via the keyboard bindings. This is the default.

Note that application code and tag bindings can set the selection however they wish, regardless of the value of **-selectmode**.

```
Command-Line Name:	-selecttype
Database Name:	selectType
Database Class:	SelectType
```

Controls how the built-in class bindings manage the selection. Options are **item** or **cell**. The selection should be cleared before switching modes. The **CheckTreeview** style works best with **item** select type.

```
Command-Line Name:	-show
Database Name:	show
Database Class:	Show
```

Controls which elements of the tree to display. May be a list containing zero or more of the following values. The default is **tree headings**.

**tree**

Display tree labels in column #0.

[**headings**](#headings)

Display the heading row.

**NOTE:** Column #0 always refers to the tree column, even if **-show tree** is not specified.

```
Command-Line Name:	-striped
Database Name:	striped
Database Class:	Striped
```

Boolean specifying zebra striped item coloring. Note that striped items uses the **-stripedbackground** option if set by the theme or a tag. If not supported by the current theme, it will not show.

```
Command-Line Name:	-titlecolumns
Database Name:	titleColumns
Database Class:	TitleColumns
```

Number of display columns at the left that should not be scrolled. The tree column counts, even if **-show tree** is not specified. Thus for value N of this option, column #N is the first one that is scrollable. The default is 0.

```
Command-Line Name:	-titleitems
Database Name:	titleItems
Database Class:	TitleItems
```

Number of items at the top that should not be vertically scrolled. The default is 0.

# [INDICES](#INDICES)

Several of the widget subcommands use an index as their argument. An index specifies a particular child item within it's parent, using any of the following forms:

[*number*](#number)

Specifies the numerical index of a child within its parent, where 0 corresponds to the first item.

[**end**](#end)

Indicates the end of the list of children. For most subcommands this refers to the last child, but for a few such as **index**, **insert**, and **move** it refers to the item just after the last one.

[**first**](#first)

Indicates the first child in the list of children.

[**last**](#last)

Indicates the last child in the list of children.

[**end-n**](#end-)

Indicates the item at position *n* relative to the end where **end-1** is the last item in the list of children.

[*m-n*](#m)

Indicates the item at position *n* relative to index *m*. See **string index** for valid forms.

# [COLUMN IDENTIFIERS](#COLUMN_IDENTIFIERS)

Column identifiers take any of the following forms:

- A symbolic name from the list defined by **-columns** option.
- An integer *n*, specifying the *n*th data column. This is an index corresponding to the columns in the **-columns** option and the value is taken from the item's **-values** option.
- A string of the form **#n**, where *n* is an integer, specifying the *n*th display column. Column **#0** is always the tree column even if not shown. The subsequent columns are defined by the **-displaycolumns** option. For example, **#1** is the first column in **-displaycolumns**.
- In the form of **end-n**, specifying the *n*th display column from the end, where **end-1** is the last displayed column.
- In the form of *m-n* or *m+n* for the *n*th data column relative to column *m*. See **string index** for valid forms.

# [WIDGET COMMAND](#WIDGET_COMMAND)

In addition to the standard **cget**, **configure**, **instate**, **state**, **style**, **xview** and **yview** subcommands (see **ttk::widget**), treeview widgets support the following additional subcommands:

[*pathname after* ?**-hidden**? ?**-norecurse**? *item*](#pathname)

Returns the identifier of the item after *item* in the current view. It can be the first child, next sibling, next sibling of an ancestor, or {} for none. Use **-hidden** to include hidden items and **-nohidden** (default) to exclude them. Use **-recurse** to include descendants/ancestors of *item* (default) and **-norecurse** to exclude them. If both **-hidden** and **-recurse** are used, descendants of closed items will be included. The **next** method is equivalent to "**after -hidden -norecurse**"

[*pathname bbox* *item* ?*column*?](#pathname~2)

Returns the bounding box (relative to the treeview widget's window) of the specified *item* in the form *x y width height*. If the *item* is not visible (i.e., if it is a descendant of a closed item or is vertically scrolled offscreen), returns the empty list. If *column* is specified and is not hidden (by the **-displaycolumns** option), returns the bounding box of that cell within *item* (even if the cell is horizontally scrolled offscreen).

[*pathname bbox {\*}cell*](#pathname~3)

Same as previous subcommand, but uses the expand operator to convert *cell* into item and column components.

[*pathname before* ?**-hidden**? ?**-norecurse**? *item*](#pathname~4)

Returns the identifier of the item before *item* in the current view. It can be the previous sibling, parent of *item*, or {} for none. Use **-hidden** to include hidden items and **-nohidden** (default) to exclude them. Use **-recurse** to include descendants/ancestors of *item* (default) and **-norecurse** to exclude them. If both **-hidden** and **-recurse** are used, descendants of closed items will be included. The **prev** method is equivalent to "**before -hidden -norecurse**"

[*pathname cellfocus* ?*cell*?](#pathname~5)

Sets the cell focus to *cell*. Use **{}** to clear the focus cell. Without *cell*, returns the current focus cell id or **{}** if none.

[*pathname cellselection* ?*selop arg ...*?](#pathname~6)

Manages cell selection. The cell selection is independent from the item selection handled by the **selection** subcommand. A cell is specified by a list of two elements, the item and the column. For the rectangle versions of these subcommands, the cells must be in displayed columns. Any change to **-columns** clears the cell selection. A *cellList* argument may be a single cell or a list of cells. If *selop* is not specified, returns a list of selected cells. Otherwise, *selop* is one of the following:

[*pathname cellselection add cellList*](#pathname~7)

Adds cells *cellList* to the cell selection.

[*pathname cellselection add* ?**-nohidden**? ?**-norecurse**? *cellFirst cellLast*](#pathname~8)

Add the cells within the rectangle defined by *cellFirst* and *cellLlast* to the cell selection. With **-nohidden**, hidden cells will be excluded and with **-norecurse**, cell in descendant items will be excluded.

[*pathname cellselection anchor* ?*cell*?](#pathname~9)

Sets the cell selection anchor to *cell*. The anchor is used as the cellFirst for the selection extend bindings. Without *cell*, the current cell selection anchor is returned. Use empty string **{}** to unset the anchor.

[*pathname cellselection has cellList*](#pathname~10)

Returns 1 if cell selection includes all of the cells in *cellList* or 0 if any are not selected.

[*pathname cellselection includes cellList*](#pathname~11)

Returns 1 if cell selection includes all of the cells in *cellList* or 0 if any are not selected.

[*pathname cellselection present*](#pathname~12)

Returns 1 if there are selected cells or 0 if none.

[*pathname cellselection remove cellList*](#pathname~13)

Remove each cell in *cellList* from the cell selection.

[*pathname cellselection remove* ?**-nohidden**? ?**-norecurse**? *cellFirst cellLast*](#pathname~14)

Remove the cells within the rectangle defined by *cellFirst* and *cellLast* from the cell selection. With **-nohidden**, hidden cells will be excluded and with **-norecurse**, cell in descendant items will be excluded.

[*pathname cellselection set cellList*](#pathname~15)

Sets the selection to the cells in *cellList*. All other cells are unselected. Use an empty set **{}** to clear the selection.

[*pathname cellselection set* ?**-nohidden**? ?**-norecurse**? *cellFirst cellLast*](#pathname~16)

Set the selection to the cells within the rectangle defined by *cellFirst* and *cellLast*. All other cells are unselected. With **-nohidden**, hidden cells will be excluded and with **-norecurse**, cell in descendant items will be excluded.

[*pathname cellselection size*](#pathname~17)

Returns the count of selected cells.

[*pathname cellselection toggle cellList*](#pathname~18)

Toggle the cell selection state of each cell in *cellList*. If the element is partially visible, the result gives the full area of the element, including any parts that are not visible.

[*pathname cellselection toggle* ?**-nohidden**? ?**-norecurse**? *cellFirst cellLast*](#pathname~19)

Toggle the selection state of the cells within the rectangle defined by *cellFirst* and *cellLast*. With **-nohidden**, hidden cells will be excluded and with **-norecurse**, cell in descendant items will be excluded.

[*pathname children item* ?*newchildren*?](#pathname~20)

If *newchildren* is not specified, returns the list of children belonging to *item*. If *newchildren* is specified, replaces *item*'s child list with *newchildren*. Items in the old child list not present in the new child list are detached from the tree. None of the items in *newchildren* may be an ancestor of *item*.

[*pathname collapse* ?*-recurse*? *itemList*](#pathname~21)

Sets all of the items in *itemList* to closed state. Same as "*pathname item item -open 0*" for each item in *itemList*. With the *-recurse* option, will also close all of their descendants. Use **{}** for root item.

[*pathname column column* ?*-option* ?*value -option value...*?](#pathname~22)

Query or modify the options for the specified *column*. If no *-option* is specified, returns a dictionary of option/value pairs. If a single *-option* is specified, returns the value of that option. Otherwise, the options are updated with the specified values. The following options may be set on each column:

[**-id name**](#id)

The column name. This is a read-only option. For example, \[*$pathname column #n -id*] returns the data column associated with display column *n*. The tree column has **-id #0**.

[**-anchor anchor**](#anchor)

Specifies how the text in this column should be aligned with respect to the cell. *Anchor* is one of **n**, **ne**, **e**, **se**, **s**, **sw**, **w**, **nw**, or **center**. See **Tk\_GetAnchor** for more information.

[**-minwidth minwidth**](#minwidth)

The minimum width of the column in pixels. The treeview widget will not make the column any smaller than **-minwidth** when the widget is resized or the user drags a heading column separator. The default is 20 pixels.

**-separator boolean**

Specifies whether or not a column separator should be drawn to the right of the column. The default is false.

[**-stretch boolean**](#stretch)

Specifies whether or not the column width should be adjusted when the widget is resized or the user drags a heading column separator. *Boolean* may have any of the forms accepted by **Tcl\_GetBoolean**. By default columns are stretchable.

[**-width width**](#width)

The width of the column in pixels. The default is 200 pixels. The specified column width may be changed by Tk in order to honor **-stretch** and/or **-minwidth**, or when the widget is resized or the user drags a heading column separator.

Use *pathname column #0* to configure the tree column.

[*pathname current*](#pathname~23)

Returns the current item id and column id, if any, or {} if none. The current item is the item under the mouse pointer. It can be used in the **&lt;Enter&gt;** and **&lt;Leave&gt;** event handlers to get the item and column for the event.

[*pathname delete itemList*](#pathname~24)

Deletes each of the items in *itemList* and all of their descendants. The root item may not be deleted. See also: **detach**.

[*pathname depth item*](#pathname~25)

Returns the number of levels between *item* and the root item.

[*pathname detach itemList*](#pathname~26)

Unlinks all of the specified items in *itemList* from the tree. The items and all of their descendants are still present and may be reinserted at another point in the tree with the **children** or **move** operations, but will not be displayed until that is done. The root item may not be detached. See also: **delete**.

[*pathname detached* ?**-all**|*item*?](#pathname~27)

Without any arguments, returns a list of all detached items, but not their descendants, in an arbitrary order. If *item* is provided, returns a Boolean value indicating whether *item* or an ancestor is detached or not. If **-all** is specified, returns a list of all the detached items and their descendants in an arbitrary order. The root item is never detached.

[*pathname exists item*](#pathname~28)

Returns 1 if the specified *item* is present in the tree, 0 if not.

[*pathname expand* ?*-recurse*? *itemList*](#pathname~29)

Set all of the items in *itemList* to open state. Same as "*pathname item item -open 1*" for each item in *itemList*. With the *-recurse* option, will also open all of their descendants. Use **{}** for root item.

[*pathname focus* ?*item*?](#pathname~30)

Sets the focus item to *item*. Use **{}** to clear focus item. Without *item*, returns the current focus item id or **{}** if none.

[*pathname haschildren item*](#pathname~31)

Returns 1 if *item* has children, 0 if not.

[*pathname heading column* ?*-option* ?*value -option value...*?](#pathname~32)

Query or modify the heading options for the specified *column*. Valid options are:

[**-anchor anchor**](#anchor~2)

Specifies how the heading text should be aligned. See **Tk\_GetAnchor** for valid values.

[**-command script**](#command)

A script to evaluate when the heading label is pressed.

Use *pathname heading #0* to configure the tree column heading.

**-image imageName**

Specifies an image to display to the right of the column heading. Ignored by Mac Aqua theme.

**-text text**

The text to display in the column heading.

**state stateSpec**

Modify or inquire about heading state. If *stateSpec* is present, sets the widget state: for each flag in stateSpec, sets the corresponding flag or clears it if prefixed by an exclamation point. To use the default sort direction indicator, set the heading to **user1** state plus either **selected** for descending sorts or **alternate** for ascending sorts. Remember to clear the states when a new heading is to be used as the sort column. Themes may set and use other states as needed for visual effects.

[*pathname hide* ?*-recurse*? *itemList*](#pathname~33)

Hide all of the items in *itemList* and all child items. Same as "*pathname item item -hidden 1*" for each item in *itemList*. With the *-recurse* option, will also hide all of their descendants. Use **{}** for root item.

[*pathname identifier item index*](#pathname~34)

Returns the identifier of the item at *index* within *item*'s list of children. See **INDICES** for valid forms of *index*.

[*pathname identify component x y*](#pathname~35)

Returns a description of the specified *component* under the point given by *x* and *y*, or the empty string if no such *component* is present at that position. The values *x* and *y* may have any of the forms acceptable to **Tk\_GetPixels**. The following subcommands are supported:

[*pathname identify region x y*](#pathname~36)

Returns one of:

[heading](#heading)

Tree heading area; use \[**pathname identify column x y**] to determine the heading number.

[separator](#separator)

Space between two column headings; \[**pathname identify column x y**] will return the display column identifier of the heading to left of the separator.

[tree](#tree)

The tree area.

[cell](#cell)

A data cell.

[*pathname identify item x y*](#pathname~37)

Returns the identifier of the item at position *x,y*.

[*pathname identify column x y*](#pathname~38)

Returns the display column identifier of the cell at position *x,y*. The tree column has ID **#0**.

[*pathname identify cell x y*](#pathname~39)

Returns the cell identifier of the cell at position *x,y*. A cell identifier is a list of item ID and column ID.

[*pathname identify element x y*](#pathname~40)

The element at position *x,y*.

[*pathname identify row x y*](#pathname~41)

Obsolescent synonym for *pathname identify item*.

See **COLUMN IDENTIFIERS** for a discussion of display columns and data columns.

[*pathname index item ?index?*](#pathname~42)

Returns the numeric index of *item* within its parent's list of children or if *index* is specified, the index of the item at *index* in *item*'s list of children. See **INDICES** for valid forms of *index*.

[*pathname insert parent index* ?**-id id**? *options...*](#pathname~43)

Creates a new item, inserts it in *parent*'s children at position *index*, and returns its identifier. See **ITEM OPTIONS** for the list of available options. Use the empty string **{}** for *parent* to create a new top-level item. See **INDICES** for valid forms of *index*. If *index* is negative or zero, the new item is inserted at the beginning; if *index* is greater than or equal to the current number of children, it is inserted at the end. If **-id** is specified, then *id* is used as the identifier of the item; *id* must not already exist in the tree. Otherwise, a new unique identifier is generated.

[*pathname insert before*|**after** *item* ?**-id id**? *options...*](#pathname~44)

Creates a new item, inserts it in *item*'s parent before or after *item*, and returns its identifier. See **ITEM OPTIONS** for the list of available options. If **-id** is specified, it is used as the identifier of the item; *id* must not already exist in the tree. Otherwise, a new unique identifier is generated.

[*pathname item item* ?*-option* ?*value -option value...*?](#pathname~45)

Query or modify the options for the specified *item*. If no *-option* is specified, returns a dictionary of option/value pairs. If a single *-option* is specified, returns the value of that option. Otherwise, the item's options are updated with the specified values. See **ITEM OPTIONS** for the list of available options.

[*pathname move item parent index*](#pathname~46)

Moves *item* to position *index* in *parent*'s list of children. If *index* is negative or zero, *item* is moved to the beginning; if greater than or equal to the number of children, it is moved to the end. See **INDICES** for valid forms of *index*. It is illegal to move an item under one of its descendants.

[*pathname move item* **before**|**after** *otherItem*](#pathname~47)

Moves *item* to before or after *otherItem* in *otherItem*'s parent's children. It is illegal to move an item under one of its descendants.

[*pathname next item*](#pathname~48)

Returns the identifier of *item*'s next sibling, or **{}** if *item* is the last child of its parent.

[*pathname parent item*](#pathname~49)

Returns the ID of the parent of *item*, or **{}** if *item* is at the top level of the hierarchy.

[*pathname prev item*](#pathname~50)

Returns the identifier of *item*'s previous sibling, or **{}** if *item* is the first child of its parent.

[*pathname range* ?**-hidden**? ?**-norecurse**? *first last*](#pathname~51)

Returns a list of items from *first* through *last*, inclusive. Use **-hidden** to include hidden items and **-nohidden** (default) to exclude them. Use **-recurse** to include descendants/ancestors of *item* (default) and **-norecurse** to exclude them. If both **-hidden** and **-recurse** are used, descendants of closed items will be included.

[*pathname search parent* ?*-option ...*? *pattern*](#pathname~52)

Searches within *parent*'s children for *pattern* and returns the identifier of the first match. Valid options are:

Comparisons

[**-ascii**](#ascii)

The values are to be compared to *pattern* as Unicode strings (the name is for backward-compatibility reasons.) This is the default.

[**-dictionary**](#dictionary)

The values are to be compared to *pattern* using dictionary-style comparisons. For search, this is the same as **-ascii** but also sets **-nocase**. NOTE: This means I18n and I018N are not the same.

[**-integer**](#integer)

The values are to be compared to *pattern* as integers. Empty values will be ignored, but non-numeric values will generate an error.

[**-nocase**](#nocase)

Comparisons are to be performed in a case-insensitive manner. Only used with **-ascii** and **-dictionary** options for the **-exact**, **-glob**, and **-regexp** matching.

[**-real**](#real)

The values are to be compared to *pattern* as floating-point values. Empty values will be ignored, but non-numeric values will generate an error.

[**-unicode**](#unicode)

Alias for **-ascii**.

Direction

[**-backwards**](#backwards)

The search is to be performed backwards starting from **-start** item or cell.

[**-forwards**](#forwards)

The search is to be performed forwards starting from **-start** item or cell. This is the default.

Pattern Matching

[**-exact**](#exact)

*Pattern* is a literal string that is compared for exact equality against each cell value. Used with **-ascii** and **-dictionary** options. This is the default.

[**-glob**](#glob)

*Pattern* is a glob-style pattern which is matched against each cell value using the same rules as the **string match** command. Used with **-ascii** and **-dictionary** options.

[**-regexp**](#regexp)

*Pattern* is an advanced regular expression that is matched against each cell value using the rules described in the **re\_syntax** reference page. Used with **-ascii** and **-dictionary** options.

Search Modifiers

[**-columns columns**](#columns)

Limit search to only the columns specified in *columns* list. The default is to search in all displayed columns. See **COLUMN IDENTIFIERS** for valid forms of *column*.

**-hidden**

Search within hidden and closed items too. The default is to exclude hidden and descendants of closed items from the search.

[**-recurse**](#recurse)

Search within all descendants of *parent*. The default is to only search within the children of *parent*.

[**-start item**|*cell*](#start)

Start the search at *item* or if the **-cell** option is also specified, then start the search at *cell*. The default start item and cell when used with the **-forwards** option is the first child of *parent* and the first display column. For the **-backwards** option, the default is the last child of *parent* (or descendant when used with **-recurse**) and the last display column. The *item* or *cell* must be a descendant of *parent*. When resuming a search, use the **before** or **after** subcommands to get the previous or next item to start the search at. All other options should be the same as the initial search including *parent*.

[**-stop item**|*cell*](#stop)

Stop the search at *item* or if the **-cell** option is also specified, then stop the search at *cell*. The default stop item and cell when used with the **-forwards** option is the last child of *parent* (or descendant when used with **-recurse**) and the last display column. For the **-backwards** option, the default is the first child of *parent* and the first display column. When used with the **-wraparound** option, the default is just before the start item or cell (in other words, the start item or cell won't be searched again). This means, to wrap-around and stop at the start item, only use the **-start** and **-wraparound** options. If the **-start** and **-stop** options both use the same item, then only that item will be searched. The *item* or *cell* must be a descendant of *parent*.

[**-wraparound**](#wraparound)

When used with the **-start** option, enables the search to wrap-round to the first/last item in *parent* to continue to the **-stop** item or cell.

Result Modifiers

[**-all**](#all)

Return the identifiers of all of the items that match *pattern* rather than only the first one.

**-cell**

Return cell ids instead of item ids. The default is to return item ids. Also switches the **-start** and **-stop** options to use cell values.

[**-not**](#not)

Negates the match, so only the items that do not match *pattern*, will be returned.

[*pathname see item* ?*column*?](#pathname~53)

Ensure that *item* is visible by setting all of *item*'s ancestors to **-open true**, and scroll the widget in the vertical direction, if necessary, so that *item* is within the visible portion of the tree. If *column* is specified, then the widget is scrolled in the horizontal direction, if necessary, so that *column* is within the visible portion of the tree. Only non-title columns and rows will be scrolled.

[*pathname see {\*}cell*](#pathname~54)

Same as previous subcommand, but uses the expand operator to convert *cell* into item and column components.

[*pathname selection* ?*selop itemList|first last*?](#pathname~55)

Manages item selection. The item selection is independent from the cell selection handled by the **cellselection** subcommand. If *selop* is not specified, returns a list of selected items. Otherwise, *selop* is one of the following:

[*pathname selection add itemList*](#pathname~56)

Add items in *itemList* to the selection.

[*pathname selection add* ?**-nohidden**? ?**-norecurse**? *first last*](#pathname~57)

Add the items from *first* to *last* (inclusive) to the selection. Use **-hidden** to include hidden items (default) and **-nohidden** to exclude them. Use **-recurse** to include descendants and ancestors (default) and **-norecurse** to exclude them. If **-hidden** and **-recurse** are used, all descendants of closed items will be included.

[*pathname selection anchor ?item*?](#pathname~58)

Sets the selection anchor to *item*. The anchor is used as the from item for the selection extend bindings. Without *item*, the current selection anchor is returned. Use empty string {} to unset the anchor.

[*pathname selection has itemList*](#pathname~59)

Returns 1 if selection includes all items in *itemList* or 0 if any are not selected.

[*pathname selection includes itemList*](#pathname~60)

Returns 1 if selection includes all items in *itemList* or 0 if any are not selected.

[*pathname selection present*](#pathname~61)

Returns 1 if there are selected items or 0 if none.

[*pathname selection remove itemList*](#pathname~62)

Remove each item in *itemList* from the selection.

[*pathname selection remove* ?**-nohidden**? ?**-norecurse**? *first last*](#pathname~63)

Remove the items from *first* to *last* (inclusive) from the selection. Use **-hidden** to include hidden items (default) and **-nohidden** to exclude them. Use **-recurse** to include descendants and ancestors (default) and **-norecurse** to exclude them. If **-hidden** and **-recurse** are used, descendants of closed items will be included.

[*pathname selection set itemList*](#pathname~64)

Sets selection to the items in *itemList*. All other items are unselected. Use an empty set **{}** to clear the selection.

[*pathname selection set* ?**-nohidden**? ?**-norecurse**? *first last*](#pathname~65)

Sets selection to the items from *first* to *last* (inclusive). Use **-hidden** to include hidden items (default) and **-nohidden** to exclude them. Use **-recurse** to include descendants and ancestors (default) and **-norecurse** to exclude them. If **-hidden** and **-recurse** are used, descendants of closed items will be included.

[*pathname selection size*](#pathname~66)

Returns the count of selected items.

[*pathname selection toggle itemList*](#pathname~67)

Toggle the selection state of each item in *itemList*.

[*pathname selection toggle* ?**-nohidden**? ?**-norecurse**? *first last*](#pathname~68)

Toggle the selection state of the items from *first* to *last* (inclusive). Use **-hidden** to include hidden items (default) and **-nohidden** to exclude them. Use **-recurse** to include descendants and ancestors (default) and **-norecurse** to exclude them. If **-hidden** and **-recurse** are used, descendants of closed items will be included.

[*pathname set item* ?*column*? ?*value*? ?*column value ...*?](#pathname~69)

Set or get *item* column values. With no *column* or *value* arguments, returns a dictionary of all column/value pairs. With only the *column* argument, returns the current value for *column*. With one or more *column* and *value* pair arguments, sets the value of each *column* to the associated *value*. Use column **#0** for the tree column. See **COLUMN IDENTIFIERS** for valid forms of *column*.

[*pathname size* ?**-hidden**? ?**-recurse**? *item*](#pathname~70)

Returns the count of children belonging to *item*. Use **-hidden** to include hidden items and **-nohidden** (default) to exclude them. Use **-recurse** to include descendants of *item* and **-norecurse** (default) to exclude them. If both **-hidden** and **-recurse** are used, descendants of closed items will be included.

[*pathname sort parent* ?*-option ...*?](#pathname~71)

Sort the children of *parent*. Valid options are:

[**-ascii**](#ascii~2)

The values are to be sorted in Unicode character code order (the name is for backward-compatibility reasons.) This is the default.

[**-dictionary**](#dictionary~2)

The values are to be sorted using dictionary-style comparisons. This is the same as **-ascii** except (a) case is ignored except as a tie-breaker and (b) if two strings contain embedded numbers, the numbers compare as integers, not characters. For example, in **-dictionary** mode, "bigBoy" sorts between "bigbang" and "bigboy", and "x10y" sorts between "x9y" and "x11y". Overrides the **-nocase** option.

[**-integer**](#integer~2)

The values are to be sorted as integers. Non-integer values will generate an error.

[**-nocase**](#nocase~2)

Comparisons are to be performed in a case-insensitive manner. Only used with **-ascii** option.

[**-real**](#real~2)

The values are to be sorted as floating-point values. Non-numeric values will generate an error.

[**-unicode**](#unicode~2)

Alias for **-ascii**.

[**-command command**](#command~2)

Use *command* as a comparison command. To compare two elements, evaluate a Tcl script consisting of command with the two elements appended as additional arguments. The script should return an integer less than, equal to, or greater than zero if the first element is to be considered less than, equal to, or greater than the second, respectively.

[**-increasing**](#increasing)

Sort the list in increasing order (“smallest” items first). This is the default.

[**-decreasing**](#decreasing)

Sort the list in decreasing order (“largest” items first).

[**-column column**](#column)

Sort based on values in column *column*. See **COLUMN IDENTIFIERS** for valid forms of *column*. The default is the first display column (**#0** if tree in -show or **#1** if not).

[**-ignoreempty**](#ignoreempty)

Used with **-integer** or **-real** to ignore empty entries. Normally these would trigger an error and abort the sort. Empty entries will be sorted first for **-increasing** and last for **-decreasing**.

[**-recurse**](#recurse~2)

Sort all descendants of *parent*. The default is to only sort the children of *parent*.

[*pathName tag args...*](#pathName)

Manages tags. Tags can be set on items as well as on cells. The set of tags is shared between items and cells. However item tagging is independent from cell tagging (for instance adding a tag on an item does not also add this tag on the cells in that item). Cell tags take precedence over item tags when drawing. The following subcommands are supported:

[*pathName tag add tagName itemList*](#pathName~2)

Adds tag *tagName* to each of the items in *itemList*. If *tagName* is already present for a particular item, then the **-tags** for that item are unchanged.

[*pathName tag bind tagName* ?*sequence*? ?*script*?](#pathName~3)

Add a Tk binding script for the event sequence *sequence* to the tag *tagName*. When an X event is delivered to an item, binding scripts for each of the item's **-tags** are evaluated in order as per [*bindtags(n)*](/man/os/tk/bindtags.n). If the event can be associated with a cell (i.e. mouse events) any bindings for the cell's **-tags** are evaluated as well.

**&lt;Key&gt;**, **&lt;KeyRelease&gt;**, and virtual events are sent to the focus item. The **&lt;Button&gt;**, **&lt;ButtonRelease&gt;**, and **&lt;Motion&gt;** events are sent to the current item under the mouse pointer. The **&lt;Enter&gt;** and **&lt;Leave&gt;** events are sent to the current item under the mouse pointer or the last item under the mouse pointer, respectively. They are used to detect when the mouse pointer enters or leaves a cell. No other event types are supported.

The binding *script* undergoes **%**-substitutions before evaluation; see [**bind**(n)](/man/os/tk/bind.n) for details.

[*pathName tag cell subcommand...*](#pathName~4)

Manages tags on individual cells. A *cellList* argument may be a single cell or a list of cells.

[*pathName tag cell add tagName cellList*](#pathName~5)

Adds tag *tagName* to each of the cells in *cellList*. If *tagName* is already present for a particular cell, then the tag list for that cell is not changed.

[*pathName tag cell has tagName* ?*cell*?](#pathName~6)

If *cell* is specified, returns a boolean value with whether *cell* has tag *tagName*. Without *cell*, a list of all cells which have tag *tagName* is returned.

[*pathName tag cell remove tagName* ?*cellList*?](#pathName~7)

Removes tag *tagName* from each of the cells in *cellList*. If *cellList* is omitted, tag *tagName* is removed from all cells in the tree.

[*pathName tag configure tagName* ?*option*? ?*value option value...*?](#pathName~8)

Query or modify the options for tag *tagName*. If one or more *option* and *value* pairs are specified, each option is set to the following value. If a single *option* is specified, the value of that option is returned (or the empty string if the option has not been specified for *tagName*). With no arguments, a dictionary of the option settings for tag *tagName* is returned. See **TAG OPTIONS** for the list of available options.

[*pathName tag delete tagName*](#pathName~9)

Deletes tag *tagName* and any associated information. The tag is deleted from all items and cells in the widget and also any other information associated with the tag is deleted, such as bindings and display information.

[*pathName tag has tagName* ?*item*?](#pathName~10)

If *item* is specified, returns a boolean value with whether *item* has tag *tagName* or not. Without *item*, returns a list of all items which have tag *tagName*.

[*pathName tag names*](#pathName~11)

Returns a list of all tags used by the widget.

[*pathName tag remove tagName* ?*itemList*?](#pathName~12)

Removes tag *tagName* from each of the items in *itemList*. If *itemList* is omitted, then tag *tagName* is removed from all items in the tree. If tag *tagName* is not present for an item, then the **-tags** for that item are not changed.

[*pathname unhide* ?*-recurse*? *itemList*](#pathname~72)

Unhide all of the items in *itemList*. Same as "*pathname item item -hidden 0*" for each item in *itemList*. With the *-recurse* option, will also unhide all of their descendants. Use **{}** for root item.

[*pathname visible item*](#pathname~73)

Returns whether *item* is visible or not. An item is visible if it is not detached, hidden, and all ancestors are open and not hidden.

# [ITEM OPTIONS](#ITEM_OPTIONS)

The following item options can be set or get with the **insert** and **item** subcommands:

[**-height**](#height)

The height of the item in multiples of **-rowheight**. The default is 1.

[**-image**](#image)

Display image *name* next to the label in the tree column, placed according to **-imageanchor**.

[**-imageanchor**](#imageanchor)

Specifies how the **-image** is to be displayed relative to the text. The default is **w**. See **Tk\_GetAnchor** for valid values.

[**-hidden**](#hidden)

A Boolean value indicating whether the item should be displayed (**false**) or hidden (**true**). If a parent is hidden, then all its descendants are hidden too.

[**-open**](#open)

A Boolean value indicating whether the item's children should be displayed (**true**) or hidden (**false**).

[**-tags**](#tags)

A list of tags associated with this item.

[**-text**](#text)

The textual label to display for the item in the tree column.

[**-values**](#values)

The list of values associated with the item. Each item should have the same number of values as the **-columns** widget option. If there are fewer values than columns, the remaining values are assumed empty. If there are more values than columns, the extra values are ignored.

[**state**](#state)

Modify or query item state. If *stateSpec* is present, sets the widget state: for each flag in stateSpec, sets the corresponding flag or clears it if prefixed by an exclamation point. Without *stateSpec*, the current states are returned. The **focus**, **selected**, and **open** states can only be set or cleared via the associated subcommands.

# [TAG OPTIONS](#TAG_OPTIONS)

The following tag options can be set or get with the **tag configure** subcommand:

[**-foreground**](#foreground)

Specifies the text foreground color.

[**-background**](#background)

Specifies the cell or item background color.

[**-font**](#font)

Specifies the font to use when drawing text.

[**-image**](#image~2)

Specifies the cell or item image.

[**-imageanchor**](#imageanchor~2)

Specifies the cell or item image anchor. See **Tk\_GetAnchor** for valid values.

[**-padding**](#padding)

Specifies the cell padding. A data cell will have a default padding of {4 0}. The value may have any of the forms acceptable to **Tk\_GetPixels**.

[**-stripedbackground**](#stripedbackground)

Specifies the cell or item background color for alternate lines, if **-striped** is true.

Tags on cells have precedence over tags on items. Then, tag priority is decided by the creation order: tags created first receive higher priority. An item's options, like **-image** and **-imageanchor**, have priority over tags.

# [IMAGES](#IMAGES)

The -image option on an item, and on an item tag, controls the image next to the label in the tree column. Other cells can have images through the cell tag -image option.

# [DEFAULT BINDINGS](#DEFAULT_BINDINGS)

The following bindings are implemented by the Treeview class. The current item is the item with the focus and the current cell is the cell with the cell focus. Unless otherwise stated, on the Mac the Option key is used in place of the Control key in the descriptions below.

When **-selecttype** is set to **item**:

- The **&lt;Left&gt;** key will close an item if it has children or if not, move the focus to the parent item and select it.
- The **&lt;Right&gt;** key will open an item if it has children.
- The **&lt;Up&gt;** key will move the focus to the previous visible item and select it. The **&lt;Shift-Up&gt;** will extend the selection to the previous visible item (multiple and extended select modes only). The **&lt;Control-Up&gt;** will move the focus to the top-most on-screen item and select it. The **&lt;Control-Shift-Up&gt;** will extend the selection to the top-most on-screen item (multiple and extended select modes only).
- The **&lt;Down&gt;** key will move the focus to the next visible item and select it. The **&lt;Shift-Down&gt;** will extend the selection to the next visible item (multiple and extended select modes only). The **&lt;Control-Down&gt;** will move the focus to the bottom-most on-screen item and select it. The **&lt;Control-Shift-Down&gt;** will extend the selection to the bottom-most on-screen item (multiple and extended select modes only).
- The **&lt;Home&gt;** key will move the focus to the first child of the current item's parent. The **&lt;Shift-Home&gt;** will extend the selection to the first child of the current item's parent (multiple and extended select modes only). The **&lt;Control-Home&gt;** (or **&lt;Command-Home&gt;** on Mac) will move the focus to the first item in the tree. The **&lt;Control-Shift-Home&gt;** (or **&lt;Command-Shift Home&gt;** on Mac) will extend the selection to the first item in the tree (multiple and extended select modes only).
- The **&lt;End&gt;** key will move the focus to the last child of the current item's parent. The **&lt;Shift-End&gt;** will extend the selection to the last child of the current item's parent (multiple and extended select modes only). The **&lt;Control-End&gt;** (or **&lt;Command-End&gt;** on Mac) will move the focus to the last item in the tree. The **&lt;Control-Shift-End&gt;** (or **&lt;Command-Shift-End&gt;** on Mac) will extend the selection to the last item in the tree (multiple and extended select modes only).
- The **&lt;Prior&gt;** key will scroll up 1 screenful and set the focus and selection to the item at the same location. The **&lt;Shift-Prior&gt;** will scroll left 1 screenful. The **&lt;Control-Prior&gt;** (or **&lt;Command-Prior&gt;** on Mac) will move to the top-most on-screen item and select it.
- The **&lt;Next&gt;** key will scroll down 1 screenful and set the focus and selection to the item at the same location. The **&lt;Shift-Next&gt;** will scroll right 1 screenful. The **&lt;Control-Next&gt;** (or **&lt;Command-Next&gt;** on Mac) will move to the bottom-most on-screen item and select it.
- The **&lt;Return&gt;** key will invoke the current item. For an item with children, will toggle open/close state or if no children toggle the selection state. The **&lt;Shift-Return&gt;** is the same as the **&lt;Return&gt;** key. The **&lt;Control-Return&gt;** and **F2** keys (or **space** and **&lt;Option-Return&gt;** on Mac) will activate the current item by calling **::ttk::treeview::ActivateItem**, if it exists, with the widget name, item, and column id arguments. If not and item has children, the open state of the current item will be toggled. Else, the item will be selected.
- The **&lt;space&gt;** key will toggle the selection state of the current item (single, multiple, and extended select modes only). The **&lt;Shift-space&gt;** will select the current item (single, multiple, and extended select modes only). The **&lt;Control-Shift-space&gt;** will select all items (multiple and extended select modes only).
- The **&lt;Tab&gt;** and **&lt;Shift-Tab&gt;** keys will move the focus to the next and previous widgets, respectively. The **&lt;Control-Tab&gt;** and **&lt;Control-Shift-Tab&gt;** keys (including Mac) will move the focus to the next and previous widgets, respectively.
- The **&lt;plus&gt;** keys will open the current item, if it has children. The **&lt;minus&gt;** keys will close the current item, if it has children. The **&lt;asterisk&gt;** key will open the current item and all of its descendants, it it has children.

When **-selecttype** is set to **cell**:

- The **&lt;Left&gt;** key will move the focus to the previous cell in the row and select it. **&lt;Shift-Left&gt;** will extend the selection to the previous cell (multiple and extended select modes only). **&lt;Control-Left&gt;** will move the focus to the left-most on-screen cell in the row and select it. **&lt;Control-Shift-Left&gt;** will extend the selection to the left-most on-screen cell in the row (multiple and extended select modes only).
- The **&lt;Right&gt;** key will move move the focus to the next cell in the row and select it. **&lt;Shift-Right&gt;** will extend the selection to the next cell (multiple and extended select modes only). **&lt;Control-Right&gt;** will move the focus to the right-most on-screen cell in the row and select it. **&lt;Control-Shift-Left&gt;** will extend the selection to the right-most on-screen cell in the row (multiple and extended select modes only).
- The **&lt;Up&gt;** key will move the focus to the above cell in the column and select it. **&lt;Shift-Up&gt;** will extend the selection to the above cell (multiple and extended select modes only). **&lt;Control-Up&gt;** will move the focus to the cell at the top of the screen in the same column and select it. **&lt;Control-Shift-Up&gt;** will extend the selection to the cell at the top of the screen in the same column (multiple and extended select modes only).
- The **&lt;Down&gt;** key will move the focus to the below cell in the column and select it. **&lt;Shift-Down&gt;** will extend the selection to the below cell (multiple and extended select modes only). **&lt;Control-Down&gt;** will move the focus to the cell at the bottom of the screen in the same column and select it. **&lt;Control-Shift-Down&gt;** will extend the selection to the cell at the bottom of the screen in the same column (multiple and extended select modes only).
- The **&lt;Home&gt;** key (and **&lt;Command-Left&gt;** on Mac) will move the focus to the first cell in the row and select it. **&lt;Shift-Home&gt;** (and **&lt;Command-Shift-Left&gt;** on Mac) will extend the selection to the first cell in the row (multiple and extended select modes only). **&lt;Control-Home&gt;** (or **&lt;Command-Home&gt;** on Mac) will move the focus to the top-left cell in the tree and select it. **&lt;Control-Shift-Home&gt;** (or **&lt;Command-Shift-Home&gt;** on Mac) will extend the selection to the top-left cell in the tree (multiple and extended select modes only).
- The **&lt;End&gt;** key (and (**&lt;Command-Right&gt;** on Mac) will move the focus to the last cell in the row and select it. **&lt;Shift-End&gt;** (and **&lt;Command-Shift-Right&gt;** on Mac) will extend the selection to the last cell in the row (multiple and extended select modes only). **&lt;Control-End&gt;** (or **&lt;Command-End&gt;** on Mac) will move the focus to the bottom-right cell in the tree and select it. **&lt;Control-Shift-End&gt;** (or **&lt;Command-Shift-End&gt;** on Mac) will extend the selection to the bottom-right cell in the tree (multiple and extended select modes only).
- The **&lt;Prior&gt;** key will scroll up 1 screenful and set the focus and selection to the cell at the same location. **&lt;Shift-Prior&gt;** will scroll left 1 screenful and set the focus and selection to the cell at the same location. **&lt;Control-Prior&gt;** (or **&lt;Command-Prior&gt;** on Mac) will move the focus to the cell at the top of the screen in the same column and select it. **&lt;Control-Shift-Prior&gt;** (or **&lt;Command-Shift-Prior&gt;** on Mac) will move the focus to the cell at the right side of the screen in the same row and select it.
- The **&lt;Next&gt;** key will scroll down 1 screenful and set the focus and selection to the cell at the same location. **&lt;Shift-Next&gt;** will scroll right 1 screenful and set the focus and selection to the cell at the same location. **&lt;Control-Next&gt;** (or **&lt;Command-Next&gt;** on Mac) will move the focus to the cell at the bottom of the screen in the same column and select it. **&lt;Control-Shift-Next&gt;** (or **&lt;Command-Shift-Next&gt;** on Mac) will move the focus to the cell at the left side of the screen in the same row and select it.
- The **&lt;Return&gt;** and **F2** keys will activate the current cell by calling **::ttk::treeview::ActivateItem**, if it exists, with the widget name, item, and column id arguments. If not, same as **&lt;Down&gt;**. **&lt;Shift-Return&gt;** is same as **Up**.
- The **&lt;space&gt;** key will toggle the selection state of the current cell (single, multiple, and extended select modes only). **&lt;Shift-space&gt;** will select all cells in the row (multiple and extended select modes only). **&lt;Control-space&gt;** (or **&lt;Command-space&gt;** on Mac) will select all cells in the column (multiple and extended select modes only). **&lt;Control-Shift-space&gt;** (or **&lt;Command-Shift-space&gt;** on Mac) will select all cells (multiple and extended select modes only).
- **&lt;Tab&gt;** is same as **Right**. **&lt;Shift-Tab&gt;** is same as **Left**. The **&lt;Control-Tab&gt;** and **&lt;Control-Shift-Tab&gt;** keys (including Mac) will move the focus to the next and previous widgets, respectively.

Applies to all:

- **&lt;Button-1&gt;** will set the focus (all modes) and selection (all except none select mode) to the item or cell under the mouse pointer.
- **&lt;B1-Motion&gt;** will drag a column separator for resize, a column heading for a column move, selected item/cell when in browse select mode, or extend the selection when in extended select mode.
- **&lt;ButtonRelease-1&gt;** will drop a column separator for resize, column heading for a move, or set the selection.
- **&lt;Double-Button-1&gt;** will activate an item or cell by calling ::ttk::treeview::ActivateItem. If pressed over a column divider, will auto size the column to its contents. This works best if columnm **-stretch** is 0. Auto size will honor the column **-minwidth** value.
- **&lt;Alt-Double-Button-1&gt;** (or **&lt;Option-Double-Button-1&gt;** for a Mac) on a column divider will auto size all columns to their contents. This works best if all columns have **-stretch** set to 0. Auto size will honor the **-minwidth** value for each column.
- **&lt;Shift-Button-1&gt;** will select a range of items or cells from the anchor to the selected item/cell (multiple and extended select modes only). If pressed in a heading when **-selecttype** is set to **cell** and in multiple or extended select mode, then all of the column cells will be selected.
- **&lt;Control-Button-1&gt;** will toggle the selection state of an item or cell (single, multiple, and extended select modes only). If pressed in a heading when **-selecttype** is set to **cell** and in multiple or extended select mode, then all of the column cells will be selected.
- **&lt;&lt;SelectAll&gt;&gt;** virtual event will select all items or cells in the widget (multiple and extended select modes only).
- **&lt;&lt;SelectNone&gt;&gt;** virtual event will unselect all items or cells (except browse mode).
- **&lt;&lt;SelectInvert&gt;&gt;** virtual event will invert or toggle the selection state of all items or cells (multiple or extended select modes only).
- The **&lt;&lt;Copy&gt;&gt;** virtual event will copy the contents of the selected items or cells to the clipboard.

# [VIRTUAL EVENTS](#VIRTUAL_EVENTS)

The treeview widget generates the following virtual events.

**&lt;&lt;TreeviewSelect&gt;&gt;**

Generated whenever the selection or cell selection changes. It may also be generated when the selection is affected but not actually changed. Furthermore, multiple selection changes could happen before events can be processed leading to multiple events with the same visible selection. Use the **selection** or **cellselection** subcommands to get the current selection.

**&lt;&lt;TreeviewOpen&gt;&gt;**

Only triggered when the tree closed indicator is pressed and generated just before setting the current item to **-open true**. To get the current item, use the detail/user\_data field (**%d**) in the binding script (see event **-detail** option) or the **current** subcommand.

**&lt;&lt;TreeviewClose&gt;&gt;**

Only triggered when the tree open indicator is pressed and generated just after setting the current item to **-open false**. To get the current item, use the detail/user\_data field (**%d**) in the binding script (see event **-detail** option) or the **current** subcommand.

**&lt;&lt;TreeviewFocus&gt;&gt;**

Triggered when the focus item or cell changes including when unset. To get the focus item and column, use the detail/user\_data field (**%d**) in the binding script (see event **-detail** option) or the use the **focus** or **cellfocus** subcommands to get the current focus. The former can return either a 1 or 2 item list with just the focus item or both the item and column.

# [STANDARD STYLES](#STANDARD_STYLES)

**Ttk::treeview** widget also support the **CheckTreeview** style in all standard themes. This style adds a checkbutton after the open/close indicator and before the item image to better show which items are selected. Combine this style with the **-selectmode multiple** option to create a check list widget where the user can easily select multiple entries without the need to use the keyboard. This style works best with the **item** select type, not **cell**.

# [STYLING OPTIONS](#STYLING_OPTIONS)

The following are the widget components for the **ttk::style** command:

- The class name for a **ttk::treeview** is **Treeview**.
- The treeview heading class name is **Heading**.
- The treeview row class name is **Row**.
- The treeview item class name is **Item**.
- The treeview cell class name is **Cell**.

Dynamic states: **active**, **background**, **disabled**, **focus**, and **selected**.

The **Treeview** styling options configurable with **ttk::style** are:

**-background** *color*

Specifies the background color of rows that contain data values.

[**-columnseparatorwidth** *amount*](#columnseparatorwidth)

Specifies the width of column separators. The default is 1 pixel. The value may have any of the forms acceptable to **Tk\_GetPixels**.

[**-fieldbackground** *color*](#fieldbackground)

Specifies the background color of the unused portion of the widget.

**-font** *font*

Specifies the the font for the contents of the tree (not heading).

**-foreground** *color*

Specifies the foreground color of rows that contain data values.

[**-headingheight** *amount*](#headingheight)

This is the default height for heading cells. If set to 0, the value will be auto calculated by measuring the heading layout with the style's settings. This includes the font size and any padding from the theme's layout.

[**-indent** *amount*](#indent)

Specifies the indentation amount of child elements below parent elements within the tree column. The default is 20 pixels. The value may have any of the forms acceptable to **Tk\_GetPixels**.

**-padding** *amount*

Specifies the additional padding to include inside the border of the widget body, including the heading. The value may have any of the forms acceptable to **Tk\_GetPixels**.

**-stripedbackground** *color*

This is the background color to use for the **-striped** option.

[**-rowheight** *amount*](#rowheight)

This is the default height for items and cells. If set to 0, the value will be auto calculated by measuring the item and cell layout with the style's settings. This includes the font size(s), focus ring, and padding from the theme's layout.

Example of how to set **-rowheight**, adapting to a font in a similar way to how the default value is set:

```
ttk::style configure Treeview \


     -rowheight [expr {[font metrics font -linespace] + 2}]
ttk::style configure Treeview \


     -headingheight [expr {[font metrics font -linespace] + 2}]
```

The **Heading** styling options configurable with **ttk::style** are:

**-background** *color*

Specifies the background color of the heading.

**-font** *font*

Specifies the the font for the heading.

**-foreground** *color*

Specifies the foreground color of the heading.

[**-indicatormargin** *amount*](#indicatormargin)

Specifies the additional padding to include around the indicator. The value may have any of the forms acceptable to **Tk\_GetPixels**. The default is "2 2 4 2".

[**-indicatorsize** *pixels*](#indicatorsize)

Specifies the size of the indicator in pixels. The default is 3.5 points.

**-padding** *amount*

Specifies the additional padding to include inside the border of the heading. The value may have any of the forms acceptable to **Tk\_GetPixels**.

[**-relief** *relief*](#relief)

Specifies the relief to use for the heading.

Example of how to set the current sorted column heading font to bold black and all other column heading fonts to normal gray similar to how the Mac Finder works:

```
ttk::style map Heading -foreground {selected black alternate black}
```

The **Row** styling options configurable with **ttk::style** are:

**-background** *color*

Specifies the background color of the tree entries. The default is same as Treeview.

[**-focuscolor** *color*](#focuscolor)

Specifies the color of the focus ring for tree entries. The default is #000000. Some themes may change the default focus color.

[**-focussolid** *boolean*](#focussolid)

Specifies whether to draw the focus ring as a dotbox (false) or solid ring (true). The default is true.

[**-focusthickness** *amount*](#focusthickness)

Specifies the thickness of the focus ring for tree entries. The default is 1 for the focus element. The value may have any of the forms acceptable to **Tk\_GetPixels**.

**-padding** *amount*

Specifies the additional padding to include between the focus ring and row contents. The default is 0. The value may have any of the forms acceptable to **Tk\_GetPixels**.

Example of how to set focus options for a spreadsheet-style focus ring that is only shown when a cell has the focus:

```
ttk::style configure Row -focuscolor #008000 -focussolid 1 -focusthickness 0
ttk::style map Row -focusthickness [list focus 2]
```

The **Item** (tree column only) styling options configurable with **ttk::style** are:

**-foreground** *color*

Specifies the foreground color of the tree items. The default is same as Treeview.

[**-indicatormargin** *amount*](#indicatormargin~2)

Specifies the additional padding to include around the indicator. The value may have any of the forms acceptable to **Tk\_GetPixels**.

[**-indicatorsize** *pixels*](#indicatorsize~2)

Specifies the size of the indicator in pixels.

**-padding** *amount*

Specifies the additional padding to include inside the border of the tree items. The value may have any of the forms acceptable to **Tk\_GetPixels**.

The **Cell** (non-tree columns) styling options configurable with **ttk::style** are:

**-padding** *amount*

Specifies the additional padding to include inside the border of the cell. The value may have any of the forms acceptable to **Tk\_GetPixels**.

Some options are only available for specific themes.

See the **ttk::style** manual page for information on how to configure ttk styles.

# [SEE ALSO](#SEE_ALSO)

[ttk::widget(n)](/man/os/tk/ttk::widget.n), [listbox(n)](/man/os/tk/listbox.n), [image(n)](/man/os/tk/image.n), [bind(n)](/man/os/tk/bind.n)

# [KEYWORDS](#KEYWORDS)

tree, treeview, widget

9.1 Tk

---

Document: ttk_treeview(n) from tk 9.1.0-r0 (Chainguard OS)
Source: https://downloads.sourceforge.net/sourceforge/tcl/tk9.1.0-src.tar.gz
