TIP 552: Extended treeview functionality.

Bounty program for improvements to Tcl and certain Tcl packages.
    Author:        Peter Spjuth <[email protected]>
    State:         Draft
    Type:          Project
    Vote:          Pending
    Created:       19-Sep-2019
    Tcl-Version:   8.7
    Keywords:      Tk, treeview
    Tk-Branch:     pspjuth-treeview


This TIP proposes a set of new features for the Ttk treeview widget.


Each time I have tried to use the Treeview widget it fell short of some feature or another and I had to resort to other means.

This aims to fill in the most common missing pieces.


The following features are added to the treeview widget.

Locked horizontal scrolling

Adds the ability to lock the first display column(s) from horizontal scrolling.

A new option -titlecolumns n is added, requesting columns to be locked. The tree column counts, even if -show tree is not specified. This is to follow the semantics of #N-indexing of columns. Thus for value N of this option, column #N is the first one that is scrollable.

Locked vertical scrolling

Adds the ability to lock the first item(s) from vertical scrolling.

A new option -titleitems n is added, requesting items to be locked.

Any individual item's visual appearance is not affected by this, just if it is shown or not. Thus if a hierarchy crosses the titleitem boundary it looks weird but works. If striped rows are used and the title items have default colors, it looks weird but works. Both those usages fall under "Don't do that then".

Cell selection

Adds the ability to select individual cells as well as full rows.

Cell selection is independent of item selection.

Cells are identified with a two element list with item id and column id.

A new subcommand cellselection is added, mirroring the present selection. In addition the cellselection set and cellselection add commands get a version for selecting a rectangular range.

A new option -selecttype type is added to direct default bindings to use either item selection or cell selection. It takes values item or cell.

The identify subcommand is updated with the cell option.

Default bindings are updated to use these features.

The <<TreeviewSelect>> virtual event triggers on any selection change including cellselection.

Striped rows

A new option -striped bool is added. This makes every other item get marked with the alternate state, and allows the theme to draw them in a different color. Built in themes are updated to put something fitting at that color.

Column separators

The -show option is extended with the value columnseparators to display a separator between columns. Built in themes are updated to define the separators.

Image anchor for tree

A new item option -imageanchor anchor is added. This controls the placement of the image relative to the text in an item's tree column. Default is "w".

Item height

A new item option -height height is added. This controls the height of the item, in multiples of -rowheight. Default is 1.


Started on branch pspjuth-treeview


This document has been placed in the public domain.