treectrl(n)

📦 version 2.4.1, in fedora 43, fedora 44

🌸 treectrl — the manual, bestie edition 🌸

okay so you found your way to treectrl(n) — that's the Tk Commands manual page for it, and honestly? it's a whole vibe. hierarchical multicolumn widgets ✨. yes that's a lot of words. no we're not scared of it. 💅


✨ NAME ✨

treectrl — Create and manipulate hierarchical multicolumn widgets 🦋

like. it makes the tree. it makes the columns. it lets you click on stuff and expand stuff and it is so much. main character widget energy, fr fr. 👑

🎀 SYNOPSIS 🎀

first things first, bestie — you gotta load the package. and this page documents version 2.4.1, no cap:

package require treectrl  2.4.1

then you make your widget with a path name and whatever options you want:

treectrl pathName ?options?

and then, the way that there are like. a hundred subcommands. every single one lives here. we're not skipping a single one because that would be rude to you. 💖 here's the whole list, exactly as the ancestors wrote it:

pathName activate itemDesc

pathName bbox ?area?

pathName canvasx windowx

pathName canvasy windowy

pathName cget option

pathName collapse ?-recurse? ?itemDesc ...?

pathName column option column ?arg ...?

pathName column bbox columnDesc

pathName column cget columnDesc option

pathName column configure columnDesc ?option? ?value? ?option value ...?

pathName column compare column1 op column2

pathName column count ?columnDesc?

pathName column create ?option value ...?

pathName column delete first ?last?

pathName column dragcget option

pathName column dragconfigure ?option? ?value? ?option value ...?

pathName column index columnDesc

pathName column id columnDesc

pathName column list ?-visible?

pathName column move columnDesc beforeDesc

pathName column neededwidth columnDesc

pathName column order columnDesc ?-visible?

pathName column tag option ?arg arg ...?

pathName column tag add columnDesc tagList

pathName column tag expr columnDesc tagExpr

pathName column tag names columnDesc

pathName column tag remove columnDesc tagList

pathName column width columnDesc

pathName compare itemDesc1 op itemDesc2

pathName configure ?option? ?value option value ...?

pathName contentbox

pathName debug option ?arg arg ...?

pathName debug alloc

pathName debug cget option

pathName debug configure ?option? ?value? ?option value ...?

pathName debug dinfo option

pathName debug expose x1 y1 x2 y2

pathName depth ?itemDesc?

pathName dragimage option ?arg ...?

pathName dragimage add itemDesc ?column? ?element?

pathName dragimage cget option

pathName dragimage clear

pathName dragimage configure ?option? ?value? ?option value ...?

pathName dragimage offset ?x y?

pathName element option ?element? ?arg arg ...?

pathName element cget element option

pathName element configure element ?option? ?value? ?option value ...?

pathName element create name type ?option value ...?

pathName element delete ?element ...?

pathName element names

pathName element perstate element option stateList

pathName element type element

pathName expand ?-recurse? ?itemDesc ...?

pathName gradient option ?arg ...?

pathName gradient cget gradient option

pathName gradient configure gradient ?option value ...?

pathName gradient create name ?option value ...?

pathName gradient delete ?name ...?

pathName gradient names

pathName gradient native ?preference?

pathName header option ?arg ...?

pathName header bbox headerDesc ?column? ?element?

pathName header compare headerDesc1 op headerDesc2

pathName header configure headerDesc ?arg ...?

pathName header count ?headerDesc?

pathName header create ?option value?

pathName header delete headerDesc

pathName header dragcget ?arg ...?

pathName header dragconfigure ?arg ...?

pathName header element ?arg ...?

pathName header id headerDesc

pathName header image headerDesc ?column? ?image? ?column image ...?

pathName header span headerDesc ?column? ?numColumns? ?column numColumns
...?

pathName header state command headerDesc ?arg ...?

pathName header style command headerDesc ?arg ...?

pathName header text headerDesc ?column? ?text? ?column text ...?

pathName header tag command headerDesc ?arg ...?

pathName identify ?-array varName? x y

pathName index itemDesc

pathName item option ?arg ...?

pathName item ancestors itemDesc

pathName item bbox itemDesc ?column? ?element?

pathName item buttonstate itemDesc ?state?

pathName item cget itemDesc option

pathName item children itemDesc

pathName item collapse itemDesc ?-animate? ?-recurse?

pathName item compare itemDesc1 op itemDesc2

pathName item complex itemDesc ?list...?

pathName item configure itemDesc ?option? ?value? ?option value ...?

pathName item count ?itemDesc?

pathName item create ?option value ...?

pathName item delete first ?last?

pathName item descendants itemDesc

pathName item dump itemDesc

pathName item element command itemDesc column element ?arg ...?

pathName item element actual itemDesc column element option

pathName item element cget itemDesc column element option

pathName item element configure itemDesc column element ?option? ?value?
?option value ...?

pathName item element perstate itemDesc column element option
?stateList?

pathName item enabled itemDesc ?boolean?

pathName item expand itemDesc ?-animate? ?-recurse?

pathName item firstchild parent ?child?

pathName item id itemDesc

pathName item image itemDesc ?column? ?image? ?column image ...?

pathName item isancestor itemDesc descendant

pathName item isopen itemDesc

pathName item lastchild parent ?child?

pathName item nextsibling sibling ?next?

pathName item numchildren itemDesc

pathName item order itemDesc ?-visible?

pathName item parent itemDesc

pathName item prevsibling sibling ?prev?

pathName item range first last

pathName item remove itemDesc

pathName item rnc itemDesc

pathName item sort itemDesc ?option ...?

pathName item span itemDesc ?column? ?numColumns? ?column numColumns
...?

pathName item state command itemDesc ?arg ...?

pathName item state define stateName

pathName item state forcolumn itemDesc column ?stateDescList?

pathName item state get itemDesc ?stateName?

pathName item state linkage stateName

pathName item state names

pathName item state set itemDesc ?lastItem? stateDescList

pathName item state undefine ?stateName ...?

pathName item style command itemDesc ?arg ...?

pathName item style elements itemDesc column

pathName item style map itemDesc column style map

pathName item style set itemDesc ?column? ?style? ?column style ...?

pathName item tag option ?arg arg ...?

pathName item tag add itemDesc tagList

pathName item tag expr itemDesc tagExpr

pathName item tag names itemDesc

pathName item tag remove itemDesc tagList

pathName item text itemDesc ?column? ?text? ?column text ...?

pathName item toggle itemDesc ?-animate? ?-recurse?

pathName marquee option ?arg ...?

pathName marquee anchor ?x y?

pathName marquee cget option

pathName marquee configure ?option? ?value? ?option value ...?

pathName marquee coords ?x1 y1 x2 y2?

pathName marquee corner ?x y?

pathName marquee identify

pathName notify option ?arg ...?

pathName notify bind ?object? ?pattern? ?+??script?

pathName notify configure object pattern ?option? ?value? ?option value
...?

pathName notify detailnames eventName

pathName notify eventnames

pathName notify generate pattern ?charMap? ?percentsCommand?

pathName notify install pattern ?percentsCommand?

pathName notify install detail eventName detail ?percentsCommand?

pathName notify install event eventName ?percentsCommand?

pathName notify linkage pattern

pathName notify linkage eventName ?detail?

pathName notify unbind object ?pattern?

pathName notify uninstall pattern

pathName notify uninstall detail eventName detail

pathName notify uninstall event eventName

pathName numcolumns

pathName numitems

pathName orphans

pathName range first last

pathName scan option args

pathName scan mark x y

pathName scan dragto x y ?gain?

pathName see itemDesc ?columnDesc? ?option value ...?

pathName selection option args

pathName selection add first ?last?

pathName selection anchor ?itemDesc?

pathName selection clear ?first? ?last?

pathName selection count

pathName selection get ?first? ?last?

pathName selection includes itemDesc

pathName selection modify select deselect

pathName state option args

pathName state define stateName

pathName state linkage stateName

pathName state names

pathName state undefine ?stateName ...?

pathName style option ?element? ?arg arg ...?

pathName style cget style option

pathName style configure style ?option? ?value? ?option value ...?

pathName style create name ?option value ...?

pathName style delete ?style ...?

pathName style elements style ?elementList?

pathName style layout style element ?option? ?value? ?option value ...?

pathName style names

pathName theme option ?arg ...?

pathName theme platform

pathName theme setwindowtheme appname

pathName toggle ?-recurse? ?itemDesc ...?

pathName xview ?args?

pathName xview

pathName xview moveto fraction

pathName xview scroll number what

pathName yview ?args?

pathName yview

pathName yview moveto fraction

pathName yview scroll number what

not me counting all of those 💀 but yes — that's the full menu, and each one gets its own explanation coming up. vibe check: we've got column, item, header, element, style, gradient, marquee, notify, state, selection, theme, debug, dragimage, plus the plain old view/scrolling crew (xview, yview, scan, bbox, canvasx, canvasy, contentbox). 🫶


okay so that's the NAME and the SYNOPSIS handled, exactly, character for character, no details dropped. 🎀 keep scrolling, bestie — there's a lot more where that came from, and it only gets more iconic from here. 🌈

✨ DESCRIPTION ✨

okay bestie, let's get into the treectrl lore 💖

treectrl pathName ?options?

The treectrl command creates a new window (given by the pathName argument) and makes it into a treectrl widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the treectrl such as its background color and relief. The treectrl command returns the path name of the new window. At the time this command is invoked, there must not exist a window named pathName, but pathName's parent must exist.

A treectrl is a listbox widget which displays items in a one- or two-dimensional arrangement. Items have a parent-child relationship with other items. Items may be arranged from top-to-bottom or from left-to-right. Items may be spread about one or more columns. Each item-column may be configured to span one or more adjacent item-columns. The visibility of items can be set individually.

Items have a set of states, which are boolean properties. For each column of an item there is a style associated, which determines how to display the item's column taking into account the item's current state set. New states may be defined to further control the appearance of items; these custom states may be turned on or off in individual columns of items.

Multiple rows of column headers are supported. Column headers have platform-native appearance on Windows, Mac OS X, and Gtk+. The appearance of column headers may be customized using styles.

Columns may be rearranged by the user using drag-and-drop. One column can be specified to display the data in a hierarchical structure. The visibility of columns can be set individually.

A treectrl can display a user-resizable selection rectangle called the marquee. Another feature, the drag image, may be used to provide feedback during drag-and-drop operations. Both of these are features commonly found in file browsers.

A treectrl can generate events when various things happen, such as changes to the selection, or a parent item being toggled open or closed. Scripts may be bound to these events. New events can be defined.

A treectrl can display a background image. The background image can be configured to be scrolled and tiled on each axis individually.

🌈 STANDARD OPTIONS 🌈

these are the standard options, bestie ✨

  • -background
  • -borderwidth
  • -cursor
  • -font
  • -highlightbackground
  • -highlightcolor
  • -highlightthickness
  • -orient
  • -relief
  • -takefocus
  • -xscrollcommand
  • -yscrollcommand
  • -foreground

See the option manual entry for details on the standard options.

💅 WIDGET SPECIFIC OPTIONS 💅

okay so these are the widget-specific options, and they are lowkey iconic 💅

  • -backgroundimage (Command-Line Switch)
    • Database Name: backgroundImage
    • Database Class: BackgroundImage
    • Specifies the name of an image to draw as the list background. Other options control whether the image is tiled and whether the image scrolls. If the image is transparent it is drawn on top of any column -itembackground colors.
  • -backgroundmode (Command-Line Switch)
    • Database Name: backgroundMode
    • Database Class: BackgroundMode
    • Specifies how the background color of items is chosen in each column. The value should be one of row, column, order, or ordervisible. The default is row. This option has only an effect for columns which have -itembackground defined as list of two or more colors (see section COLUMNS below for more on this). If row or column is specified, the background color is chosen based on the location of the item in the 1- or 2-dimensional grid of items as layed out on the screen; this layout of items is affected by the -orient and -wrap options as well as item visibility. When order or ordervisible is specified, the background color is chosen based on the result of the item order command, regardless of the layout of items.
  • -bgimage (Command-Line Switch)
    • Database Name: bgImage
    • Database Class: BgImage
    • Synonym for -backgroundimage.
  • -bgimageanchor (Command-Line Switch)
    • Database Name: bgImageAnchor
    • Database Class: BgImageAnchor
    • Specifies how the background image should be aligned in any of the forms acceptable to Tk_GetAnchor. Must be one of the values n, ne, e, se, s, sw, w, nw, or center. The default is nw. When the background image scrolls, the anchor position is relative to the canvas, otherwise it is relative to the contentbox.
  • -bgimageopaque (Command-Line Switch)
    • Database Name: bgImageOpaque
    • Database Class: BgImageOpaque
    • Specifies a boolean indicating whether or not the background image is fully opaque. This is needed because there is no way in Tk to determine whether an image contains transparency or not. The default value is true, so if you use a transparent -backgroundimage you must set this to false.
  • -bgimagescroll (Command-Line Switch)
    • Database Name: bgImageScroll
    • Database Class: BgImageScroll
    • Specifies whether the background image scrolls along with the items or whether it remains locked in place relative to the edges of the window. The value must be a string that contains zero or more of the characters x or y. The default is xy.
  • -bgimagetile (Command-Line Switch)
    • Database Name: bgImageTile
    • Database Class: BgImageTile
    • Specifies whether the background image is tiled along the x and/or y axes. The value must be a string that contains zero or more of the characters x or y. The default is xy.
  • -buttonbitmap (Command-Line Switch)
    • Database Name: buttonBitmap
    • Database Class: ButtonBitmap
    • Specifies the name of a bitmap be used to display the expand/collapse button of an item. This is a per-state option. If a bitmap is specified for a certain item state, it overrides the effects of -usetheme.
  • -buttoncolor (Command-Line Switch)
    • Database Name: buttonColor
    • Database Class: ButtonColor
    • Specifies the foreground color which should be used for drawing the outline and the plus or minus sign of an item's expand/collapse button.
  • -buttonimage (Command-Line Switch)
    • Database Name: buttonImage
    • Database Class: ButtonImage
    • Specifies the name of an image to be used to display the expand/collapse button of an item. This is a per-state option. If an image is specified for a certain item state, it overrides the effects of -buttonbitmap and -usetheme.
  • -buttonsize (Command-Line Switch)
    • Database Name: buttonSize
    • Database Class: ButtonSize
    • Specifies the width and height of the expand/collapse button of an item in any of the forms acceptable to Tk_GetPixels.
  • -buttonthickness (Command-Line Switch)
    • Database Name: buttonThickness
    • Database Class: ButtonThickness
    • Specifies the width of the outline and the plus or minus sign of the expand/collapse button of an item in any of the forms acceptable to Tk_GetPixels.
  • -buttonttracking (Command-Line Switch)
    • Database Name: buttonTracking
    • Database Class: ButtonTracking
    • Specifies a boolean that determines if the expand/collapse buttons are tracked like pushbuttons when clicking them. When true, buttons are not toggled until the <ButtonRelease> event occurs over them. When false, buttons are toggled as soon as the <ButtonPress> event occurs over them. This option defaults to true on Mac OS X and Gtk+, false on Win32 and X11.
  • -canvaspadx (Command-Line Switch)
    • Database Name: canvasPadX
    • Database Class: CanvasPadX
    • Specifies the width of extra whitespace on the left and right edges of the canvas in any of the forms acceptable to Tk_GetPixels. The option value may be a list of one or two screen distances to specify padding for the two edges separately. The default is 0.
  • -canvaspady (Command-Line Switch)
    • Database Name: canvasPadY
    • Database Class: CanvasPadY
    • Specifies the height of extra whitespace on the top and bottom edges of the canvas in any of the forms acceptable to Tk_GetPixels. The option value may be a list of one or two screen distances to specify padding for the two edges separately. The default is 0.
  • -columnprefix (Command-Line Switch)
    • Database Name: columnPrefix
    • Database Class: ColumnPrefix
    • Specifies an ascii string that changes the way column ids are reported and processed. If this option is a non-empty string, the usual integer value of a column id is prefixed with the given string. This can aid debugging but it is important your code doesn't assume column ids are integers if you use it.
  • -columnproxy (Command-Line Switch)
    • Database Name: columnProxy
    • Database Class: ColumnProxy
    • If this option specifies a non empty value, it should be a screen distance in any of the forms acceptable to Tk_GetPixels. Then a 1 pixel thick vertical line will be drawn at the specified screen distance from the left edge of the treectrl widget, which reaches from top to bottom of the treectrl widget and uses an inverting color (i.e black on lighter background, white on darker background). This line can be used to give the user a visual feedback during column resizing.
  • -columnresizemode (Command-Line Switch)
    • Database Name: columnResizeMode
    • Database Class: ColumnResizeMode
    • Specifies the visual feedback used when resizing columns. The value should be one of proxy or realtime. For proxy, a 1-pixel thick vertical line is drawn representing where the right edge of the column will be after resizing. For realtime, the column's size is changed while the user is dragging the right edge of the column. The default is realtime.
  • -columntagexpr (Command-Line Switch)
    • Database Name: columnTagExpr
    • Database Class: ColumnTagExpr
    • Specifies a boolean that enables or disables tag expressions in column descriptions. See ITEM AND COLUMN TAGS.
  • -defaultstyle (Command-Line Switch)
    • Database Name: defaultStyle
    • Database Class: DefaultStyle

This option is deprecated, bestie — use the column option -itemstyle instead. ✨ It specifies a list of styles, one per column, to apply to each item created by the item create command. The number of styles in the list can be different from the number of tree columns. Each list element should be a valid style name or an empty string to indicate no style should be applied to a specific column. The list of styles is updated if a style is deleted or if a column is moved. 💅

  • -doublebuffer — Database Name: doubleBuffer, Database Class: DoubleBuffer. This option no longer has any effect, but was left in for compatibility. It used to control the amount of double-buffering that was used when displaying a treectrl. 💀
  • -headerfont — Database Name: headerFont, Database Class: Font. Specifies the font to draw text in column headers with. The default value is TkHeadingFont where available (on Tk 8.5+). This option can be overridden by setting the -font option for individual column headers. 🎀
  • -headerfg — Database Name: headerForeground, Database Class: Foreground. Synonym for -headerforeground. No cap, it's literally the same thing. 🙈
  • -headerforeground — Database Name: headerForeground, Database Class: Foreground. Specifies the color to draw text in column headers with. The default value is the Tk button foreground color (usually black). On Gtk+, the system theme may override this color. This option (and the Gtk+ system theme color) can be overridden by setting the -textcolor option for individual column headers. 🌈
  • -height — Database Name: height, Database Class: Height. Specifies the desired height for the window in any of the forms acceptable to Tk_GetPixels. The default is 200 pixels. If this option is less than or equal to zero then the window will not request any size at all. It's giving "no opinion" energy. 💅
  • -indent — Database Name: indent, Database Class: Indent. Specifies the screen distance an item is indented relative to its parent item in any of the forms acceptable to Tk_GetPixels. The default is 19 pixels. 🦋
  • -itemgapx — Database Name: itemGapX, Database Class: ItemGapX. Specifies the horizontal spacing between adjacent items in any of the forms acceptable to Tk_GetPixels. The default is 0. ✨
  • -itemgapy — Database Name: itemGapY, Database Class: ItemGapY. Specifies the vertical spacing between adjacent items in any of the forms acceptable to Tk_GetPixels. The default is 0. 🌸
  • -itemheight — Database Name: itemHeight, Database Class: ItemHeight. Specifies a fixed height for every item in any of the forms acceptable to Tk_GetPixels. If non-zero, this option overrides the requested height of an item and the -minitemheight option. If an item's own -height option is specified then that is the height used for the item. In any case, items are never shorter than the maximum height of a button if they display one. The default is 0. 🔥
  • -itemprefix — Database Name: itemPrefix, Database Class: ItemPrefix. Specifies an ascii string that changes the way item ids are reported and processed. If this option is a non-empty string, the usual integer value of an item id is prefixed with the given string. This can aid debugging but it is important your code doesn't assume item ids are integers if you use it. 🫶
  • -itemtagexpr — Database Name: itemTagExpr, Database Class: ItemTagExpr. Specifies a boolean that enables or disables tag expressions in item descriptions. See ITEM AND COLUMN TAGS. 👑
  • -itemwidth — Database Name: itemWidth, Database Class: ItemWidth. Specifies a fixed width for every item in any of the forms acceptable to Tk_GetPixels. If more than one column is visible, then this option has no effect. If the -orient option is vertical, and the -wrap option is unspecified, then this option has no effect (in that case all items are as wide as the column). 💜
  • -itemwidthequal — Database Name: itemWidthEqual, Database Class: ItemWidthEqual. Specifies a boolean that says whether all items should have the same width. If more than one column is visible, then this option has no effect. If the -orient option is vertical, and the -wrap option is unspecified, then this option has no effect (in that case all items are as wide as the column). If the -itemwidth option is specified, then this option has no effect. 🧚
  • -itemwidthmultiple — Database Name: itemWidthMultiple, Database Class: ItemWidthMultiple. Specifies a screen distance that every item's width will be evenly divisible by in any of the forms acceptable to Tk_GetPixels. If more than one column is visible, then this option has no effect. If the -orient option is vertical, and the -wrap option is unspecified, then this option has no effect (in that case all items are as wide as the column). If the -itemwidth option is specified, then this option has no effect. ⭐
  • -linecolor — Database Name: lineColor, Database Class: LineColor. Specifies the color which should be used for drawing the connecting lines between related items. 🌈
  • -linestyle — Database Name: lineStyle, Database Class: LineStyle. Specifies the appearance of the connecting lines between related items. The value should be dot, which is the default, or solid. 💅
  • -linethickness — Database Name: lineThickness, Database Class: LineThickness. Specifies the thickness of the connecting lines between related items in any of the forms acceptable to Tk_GetPixels. 🎀
  • -minitemheight — Database Name: minItemHeight, Database Class: MinItemHeight. Specifies a minimum height for every item in any of the forms acceptable to Tk_GetPixels. The default is 0, which means that every item has the height requested by the arrangement of elements in each column. This option has no effect if either the -itemheight widget option or -height item option is specified. In any case, items are never shorter than the maximum height of an expand/collapse button. 🦋
  • -rowproxy — Database Name: rowProxy, Database Class: RowProxy. If this option specifies a non empty value, it should be a screen distance in any of the forms acceptable to Tk_GetPixels. Then a 1 pixel thick horizontal line will be drawn at the specified screen distance from the top edge of the treectrl widget, which reaches from left to right of the treectrl widget and uses an inverting color (i.e black on lighter background, white on darker background). This line can be used to give the user a visual feedback during row resizing. 🔥
  • -scrollmargin — Database Name: scrollMargin, Database Class: ScrollMargin. Specifies a positive screen distance in any of the forms acceptable to Tk_GetPixels. This option is used by the default bindings to determine how close to the edges of the contentbox the mouse pointer must be before scrolling occurs. Specifying a positive value is useful when items may be drag-and-dropped. Defaults to 0. ✨
  • -selectmode — Database Name: selectMode, Database Class: SelectMode. Specifies one of several styles for manipulating the selection. The value of the option may be arbitrary, but the default bindings expect it to be either single, browse, multiple, or extended; the default value is browse. 👑
  • -showbuttons — Database Name: showButtons, Database Class: ShowButtons. Specifies a boolean value that determines whether this widget leaves indentation space to display the expand/collapse buttons next to items. The default value is true. The item option -button determines whether an item has a button. See also the widget options -showrootbutton and -showrootchildbuttons. 🎀
  • -showheader — Database Name: showHeader, Database Class: ShowHeader. Specifies a boolean value that determines whether this widget should display the header line with the column names at the top of the widget. The default value is true. 🌸
  • -showlines — Database Name: showLines, Database Class: ShowLines. Specifies a boolean value that determines whether this widget should draw the connecting lines between related items. The default value is true on Win32 and X11, false on Mac OS X and Gtk+. 🦋
  • -showroot — Database Name: showRoot, Database Class: ShowRoot. Specifies a boolean value that determines whether this widget should draw the root item. By suppressing the drawing of the root item the widget can have multiple items that appear as toplevel items. The default value is true. 💜
  • -showrootbutton — Database Name: showRootButton, Database Class: ShowRootButton. Specifies a boolean value that determines whether this widget leaves indentation space to display the expand/collapse button next to the root item. The default value is false. The item option -button determines whether the root item has a button. 🧚
  • -showrootchildbuttons — Database Name: showRootChildButtons, Database Class: ShowRootChildButtons. Specifies a boolean value that determines whether this widget should draw the expand/collapse buttons next to children of the root item. The default value is true. ⭐
  • -showrootlines — Command-Line Switch: -showrootlines · Database Name: showRootLines · Database Class: ShowRootLines
    • Specifies a boolean value that decides whether this widget should draw the connecting lines between the children of the root item. The default value is true. 🌸
  • -treecolumn — Command-Line Switch: -treecolumn · Database Name: treeColumn · Database Class: TreeColumn
    • Specifies a column description that determines which column displays the expand/collapse buttons and connecting lines between items. The default is unspecified. 👑
  • -usetheme — Command-Line Switch: -usetheme · Database Name: useTheme · Database Class: UseTheme
    • Specifies a boolean value that determines whether this widget should draw parts of itself using a platform-specific theme manager. The default is true. ✨
  • -width — Command-Line Switch: -width · Database Name: width · Database Class: Width
    • Specifies the desired width for the window, in any of the forms acceptable to Tk_GetPixels. The default is 200 pixel. If this option is less than or equal to zero then the window will not request any size at all. 🎀
  • -wrap — Command-Line Switch: -wrap · Database Name: wrap · Database Class: Wrap
    • Specifies whether items are arranged in a 1- or 2-dimensional layout.
    • If the value is an empty string (the default), then items are arranged from top to bottom (-orient=vertical) or from left to right (-orient=horizontal) in a 1-dimensional layout. 🌈
    • If the value is "N items", then no more than N items will appear in a vertical group (-orient=vertical) or horizontal group (-orient=horizontal).
    • If the value is "N pixels", then no vertical group of items will be taller than N pixels (-orient=vertical) or no horizontal group of items will be wider than N pixels (-orient=horizontal).
    • If the value is window, then a no vertical group of items will be taller than the window (-orient=vertical) or no horizontal group of items will be wider than the window (-orient=horizontal).
    • It is also possible to cause wrapping to occur on a per-item basis by using the item option -wrap. See the item create command for that option.
  • -xscrolldelay — Command-Line Switch: -xscrolldelay · Database Name: xScrollDelay · Database Class: ScrollDelay
    • This option controls how quickly horizontal scrolling occurs while dragging the mouse with button 1 pressed. The value should be a list of 1 or 2 integers interpreted as milliseconds. If 2 values are specified, then the first value determines the intial delay after the first scroll, and the second value determines the delay for all scrolling after the first. If only 1 value is specified, each scroll takes place after that delay. 💅
  • -xscrollincrement — Command-Line Switch: -xscrollincrement · Database Name: xScrollIncrement · Database Class: ScrollIncrement
    • Specifies an increment for horizontal scrolling, in any of the usual forms permitted for screen distances. If the value of this option is greater than zero, the horizontal view in the window will be constrained so that the canvas x coordinate at the left edge of the window is always an even multiple of -xscrollincrement; furthermore, the units for scrolling (e.g., the change in view when the left and right arrows of a scrollbar are selected) will also be -xscrollincrement. If the value of this option is less than or equal to zero, then horizontal scrolling snaps to the left of an item, or part of an item if items are wider than the contentbox. 🦋
  • -xscrollsmoothing — Command-Line Switch: -xscrollsmoothing · Database Name: xScrollSmoothing · Database Class: ScrollSmoothing
    • Specifies whether scrolling should be done as if -xscrollincrement=1 whenever scrolling is performed by non-unit amounts. When the value of this option is true and the xview command is called to scroll by "units", scrolling occurs according to the -xscrollincrement option, and all other scrolling is done as if the -xscrollincrement option was set to 1. The effect is that when dragging the scrollbar thumb scrolling is very smooth, but when clicking the scrollbar buttons scrolling is done in coarser increments. The default value is false. 🌸
  • -yscrolldelay — Command-Line Switch: -yscrolldelay · Database Name: yScrollDelay · Database Class: ScrollDelay
    • This option controls how quickly vertical scrolling occurs while dragging the mouse with button 1 pressed. The value should be a list of 1 or 2 integers interpreted as milliseconds. If 2 values are specified, then the first value determines the intial delay after the first scroll, and the second value determines the delay for all scrolling after the first. If only 1 value is specified, each scroll takes place after that delay. 💜
  • -yscrollincrement — Command-Line Switch: -yscrollincrement · Database Name: yScrollIncrement · Database Class: ScrollIncrement
    • Specifies an increment for vertical scrolling, in any of the usual forms permitted for screen distances. If the value of this option is greater than zero, the vertical view in the window will be constrained so that the canvas y coordinate at the top edge of the window is always an even multiple of -yscrollincrement; furthermore, the units for scrolling (e.g., the change in view when the top and bottom arrows of a scrollbar are selected) will also be -yscrollincrement. If the value of this option is less than or equal to zero, then vertical scrolling snaps to the top of an item, or part of an item if items are taller than the contentbox. 🍓
  • -yscrollsmoothing — Command-Line Switch: -yscrollsmoothing · Database Name: yScrollSmoothing · Database Class: ScrollSmoothing
    • Specifies whether scrolling should be done as if -yscrollincrement=1 whenever scrolling is performed by non-unit amounts. When the value of this option is true and the yview command is called to scroll by "units", scrolling occurs according to the -yscrollincrement option, and all other scrolling is done as if the -yscrollincrement option was set to 1. The effect is that when dragging the scrollbar thumb scrolling is very smooth, but when clicking the scrollbar buttons scrolling is done in coarser increments. The default value is false. ⭐

🎨 THE CANVAS

Throughout this manual page the term canvas is sometimes used. The canvas can be thought of as the virtual sheet of paper upon which all visible items are drawn. The treectrl window displays different areas of the canvas within its borders as the list is scrolled. 🖼️


🦋 ITEM AND COLUMN TAGS

Columns and items may have any number of tags associated with them. A tag is just a string of characters, and it may take any form, including that of an integer, although the characters '(', ')', '&', '|', '^' and '!' should be avoided. 🙈

The same tag may be associated with many columns or items. This is commonly done to group items in various interesting ways; for example, in a file browser all directories might be given the tag "directory". 📁

Tag expressions are used in column descriptions and item descriptions to specify which columns and items to operate on. A tag expression can be a single tag name or a logical expression of tags using operators '&&', '||', '^' and '!', and parenthesized subexpressions. For example:

or equivalently:

will return the unique ids of any items with either "a" or "b" tags, but not both. 👑

Within a tag expression a tag name may be enclosed in double quotes to avoid special processing of the operator characters. For example:

will return the unique ids of any items with either "a&&b" or "c" tags; in this example the && is not treated as an operator. A double-quote may be escaped within a quoted tag name using a backslash '\'. 💅

Tag operators may be bypassed completely by setting the -columntagexpr and -itemtagexpr options. This can be useful if your application has column or item tags containing arbitrary text. ✨


👑 WIDGET COMMAND

The treectrl command creates a new Tcl command whose name is the same as the path name of the treectrl's window. This command may be used to invoke various operations on the widget. It has the following general form:

pathName option ?arg arg ...?

PathName is the name of the command, which is the same as the treectrl widget's path name. Option and the args determine the exact behavior of the command. The following commands are possible for treectrl widgets: 🫶

  • pathName activate itemDesc — Sets the active item to the one described by itemDesc, and switches on the state active for that item. The active item can be referred to by the item description active. If this command changes which item is active an <ActiveItem> event is generated. If the active item is deleted the root item becomes the new active item. 🔥
  • pathName bbox ?area? — Returns a list with four elements giving the bounding box (left, top, right and bottom) of an area of the window. If area is not specified, then the result is the bounding box of the entire window. If area is content, then the result is the part of the window not including borders, headers, or locked columns. If area is header, then the result is the part of the window not including borders where column titles are displayed. If area is left, then the result is the part of the window not including borders or headers where left-locked columns are displayed. If area is right, then the result is the part of the window not including borders or headers where right-locked columns are displayed. 📐
    • If area is one of header.left, header.none or header.right then the area of the column headers occupied by columns with -lock=left, -lock=none or -lock=right is returned.
    • An empty string is returned if the display area has no height or width, which can be true for various reasons such as the window is too small, or the header is not displayed, or there aren't any locked columns. 😭
  • pathName canvasx windowx — Translates the given window x-coordinate windowx in the treectrl to canvas coordinate space. The marquee command expects canvas coordinates. 🌸
  • pathName canvasy windowy — takes a window y-coordinate windowy inside the treectrl and translates it into canvas coordinate space 💫. Why do you care? Because the marquee command is out here speaking canvas coordinates, so this is your translator bestie.
  • pathName cget option — hands you the current value of the config option named option 🎀. And option can be literally any of the values the tree command accepts. no gatekeeping.
  • pathName collapse ?-recurse? ?itemDesc ...? — Deprecated. Use item collapse instead 🙈. she's retired, move on.
  • pathName column option column ?arg ...? — the whole column-manipulation command, and yes she's a big one (peep the COLUMNS section below 👀). What she actually does depends on the option that comes right after column. Here's every form:
    • pathName column bbox columnDesc — gives you a list of four elements, the bounding box of the header of the column described by columnDesc 📦. Those coordinates are relative to the top-left corner of the widget. And if the column's -visible=false or the widget's -showheader=false, you get an empty list back. nothing to measure, nothing to report ✨.
    • pathName column cget columnDesc option — returns the current value of the option named option for the column described by columnDesc. ColumnDesc can also be the string tail to mean the tail column 🦋. And option can be any of the values accepted by the column configure widget command.
    • pathName column configure columnDesc ?option? ?value? ?option value ...? — basically the configure widget command's cousin, except she modifies options on the columns described by columnDesc instead of the treectrl widget as a whole 💅. ColumnDesc may be the string tail for the tail column. If columnDesc points at more than one column, then you must give at least one option-value pair — that's not a vibe suggestion, that's a rule. If no option is given, you get a list describing all the available options for columnDesc (see Tk_ConfigureInfo for how that list is formatted). If option is given with no value, you get a list describing just that one named option (identical to the matching sublist from the no-option version). And if one or more option-value pairs are given, she modifies those option(s) to those value(s) for columnDesc and returns an empty string. See COLUMNS below for the deets on column options.
For compatibility with older versions of treectrl (the ones that did not support more than one row of column headers), any of the configuration options mentioned in the HEADERS section — stuff like -arrow, -text, etc — may be passed to the top header-row through this command 🧚. legacy support, we love her.
  • pathName column compare column1 op column2 — grabs the index for both column1 and column2 (as returned from the column order widget command), then compares those indexes with the operator op, which has to be one of <, <=, ==, >=, >, or !=. Returns 1 if the comparison came out true, 0 otherwise ⭐.
  • pathName column count ?columnDesc? — with no extra arguments, you get a decimal string with the number of columns created by the column create widget command that haven't been deleted by column delete; and heads up, the tail column is not counted here 🍓. If columnDesc is given, you get the number of columns matching that column description.
  • pathName column create ?option value ...? — makes a brand new column in the treectrl 🌈. She gets placed to the right of all the other columns (except the tail column, she's special). Any option-value arguments configure the new column according to the column configure command. Return value is the unique identifier of the new column — screenshot it, you'll need it 💖.
  • pathName column delete first ?last? — deletes the specified column(s). First and last must be valid column descriptions. If you give both, they may only refer to a single column. The tail column cannot be deleted and specifying it is an error 🚫. The order of first and last doesn't matter, and first may equal last. flexible queen.
  • pathName column dragcget option — Deprecated. Use header dragcget instead 😭.
  • pathName column dragconfigure ?option? ?value? ?option value ...? — Deprecated. Use header dragconfigure instead 😭.
  • pathName column index columnDesc — Deprecated. Use column id instead 💀.
  • pathName column id columnDesc — resolves the column description columnDesc into a list of unique column identifiers 🫶. If the column(s) described by columnDesc don't exist, you get an empty list. simple as.
  • pathName column list ?-visible? — returns a list of identifiers for every column (except the tail) from left to right 📋. If -visible is given, only columns whose -visible option is true make the cut ✨.
  • pathName column move columnDesc beforeDesc — moves the column described by columnDesc to the left of the column described by beforeDesc. Both must be valid column descriptions. And if beforeDesc is the string tail, then columnDesc becomes the last column 👑.
  • pathName column neededwidth columnDesc — a decimal string giving the needed width of the column described by columnDesc 📏. The needed width is the max of the width of the column header and the width of the widest style in any visible item.
Heads up: when an item style or column header spans multiple columns, the needed width of a column is affected by the widths of the other columns in that span, in which case the result of this command isn't particularly useful 💀. she said it, not me.
  • pathName column order columnDesc ?-visible? — a decimal string giving the position of the column described by columnDesc in the list of columns, starting at zero for the leftmost column 🔢. If -visible is given, only columns whose -visible option is true get considered, and -1 is returned if columnDesc's -visible option is false.
  • pathName column tag option ?arg arg ...? — manipulates tags on columns 🎀. What she does depends on the option that follows column tag. Supported forms:
    • pathName column tag add columnDesc tagList — adds each tag in tagList to the columns described by columnDesc 💖. Duplicate tags are ignored. You can also change a column's tag list via that column's -tags option.
    • pathName column tag expr columnDesc tagExpr — evaluates the tag expression tagExpr against every column described by columnDesc. Result is 1 if the tag expression evaluates to true for every column, 0 otherwise ⭐.
    • pathName column tag names columnDesc — returns a list of tag names assigned to the columns described by columnDesc. The result is the union of any tags assigned to the columns 🦋.
    • pathName column tag remove columnDesc tagList — removes each tag in tagList from the columns described by columnDesc. It is not an error if any of the columns don't use any of those tags, so don't stress 💅. You can also change a column's tag list via that column's -tags option.
  • pathName column width columnDesc — a decimal string giving the width in pixels of the column described by columnDesc 🍓 — and she gives it to you even if the treectrl is configured to not display column headers via the -showheader option. the width is still the width, periodt.
  • pathName compare itemDesc1 op itemDesc2 — Deprecated. Use the item compare command instead 🙈.
  • pathName configure ?option? ?value option value ...? — query or modify the configuration options of the widget 💖. No option? You get a list describing all the available options for pathName (see Tk_ConfigureInfo for the format of that list). Option with no value? You get a list describing that one named option (identical to the matching sublist from the no-option version). One or more option-value pairs? She modifies those widget option(s) to those value(s), and in that case the command returns an empty string 🌸. And option may have any of the values accepted by the treectrl command.

pathName contentbox

Gives you back a list of four numbers — the bounding box of the on-screen area where items actually get drawn, bestie. ✨ That's the window minus borders, minus column headers, minus locked columns. If the display area has literally zero height or zero width (which, real talk, happens when the window is smol 🥺), you get an empty string back. Oh and btw, this is the exact same result as bbox content. Same vibe, different command name. 💅


pathName debug option ?arg arg ...?

Okay so this one is the ✨debug girlie✨ of the widget — it exists so you can poke at treectrl's insides when something's being weird. 🐛 What it actually does depends on whatever option you pass after debug. Here's every form it supports:

  • pathName debug alloc — hands you a string with partial statistics on memory allocations, but ONLY if the package was built with TREECTRL_DEBUG defined. No debug build, no stats. F in the chat. 💀
  • pathName debug cget option — returns the current value of the debugging option named option. option can be any of the values that debug configure accepts. Basically the little sibling that just reads. 🙈
  • pathName debug configure ?option? ?value? ?option value ...? — just like the configure widget command, except it messes with debugging options instead of the overall treectrl widget's options. 🌸
    • No option given? You get a list describing all the available debugging options (peep Tk_ConfigureInfo for how that list is formatted).
    • option given with no value? You get a list describing just that one named option — and it'll be identical to the matching sublist from the no-option version.
    • One or more option-value pairs? It sets those debugging option(s) to those value(s), and returns an empty string. Slay.

These are the debugging options that exist, periodt:

  • -displaydelay millis — a time duration in milliseconds to wait after something's been drawn to the screen. Only does anything if the debugging options -enable and -display are both switched on. ⏱️
  • -data boolean — if this is switched on (together with the debugging option -enable), a consistency check gets run on the internal data structure in various places (like, for every item it checks whether the registered number of children equals the number of actual child items). Find an inconsistency and it raises a Tcl background error. Not me catching bugs in 4K. 🔍
  • -display boolean — if this is switched on (together with the debugging option -enable), extra debugging output gets printed to stdout in various places. (Yes, the manpage says "varios" — we love a typo, iconic. 💀)
  • -drawcolor color — when specified, areas of the window get painted with this color right when drawing in those areas is about to happen. Only has an effect if the debugging options -enable and -display are switched on. 🎨
  • -enable boolean — every other debugging option only takes effect if this one is also switched on. She's the main character, fr fr. 👑
  • -erasecolor color — when specified, areas of the window that have been marked as "invalid" (like when part of the window is exposed) get painted with this color. Pro tip from the page itself: use an unusual color (like pink 🎀) and superfluous screen redraws become way easier to spot. Only has an effect if the debugging options -enable and -display are switched on.
  • -span boolean — debugging related to column spanning.
  • -textlayout boolean — debugging related to text-element layout.
  • pathName debug dinfo option — returns a string describing display-related stuff. option must be one of alloc, ditem, onscreen or range.
  • pathName debug expose x1 y1 x2 y2 — marks the area of the window bounded by those window-coords as invalid. It's basically simulating part of the window getting uncovered. ✨

pathName depth ?itemDesc?

Give it an itemDesc and you get back a decimal string with the depth of that item — where depth means the number of ancestors an item has. 🌳 Don't give it an itemDesc and it returns the maximum depth across every item in the treectrl widget instead. Either way, numbers only.


pathName dragimage option ?arg ...?

Ooh okay, this is the drag image command — it's what gives you that feedback when items are drag-and-dropped around inside the window. 🫶 The drag image shows up as dotted outlines of one or more items, columns and/or elements. What it does depends on the option you hand it after dragimage. Supported forms:

  • pathName dragimage add itemDesc ?column? ?element? — adds the shapes of the item described by itemDesc to the dragimage's shapes. More arguments = fewer rectangles added. 🎯
    • No extra args? Every element of the item in every column gets a dotted rectangle added.
    • column specified? All elements in other columns get ignored.
    • element also specified? Only a rectangle for that one element of the specified item in the given column gets added. Precision. 💅
  • pathName dragimage cget option — returns the current value of the dragimage option named option. option can be any value accepted by dragimage configure.
  • pathName dragimage clear — removes all shapes (if there are any) from the dragimage. Important: this does not touch the dragimage offset. 🙅♀️
  • pathName dragimage configure ?option? ?value? ?option value ...? — same deal as the configure widget command, except it modifies the dragimage options instead of the overall treectrl widget's options.
    • No option? You get a list describing all available dragimage options (again, Tk_ConfigureInfo explains the format).
    • option with no value? You get a list describing that one named dragimage option — identical to the corresponding sublist from the no-option result.
    • One or more option-value pairs? It sets them and returns an empty string.

The dragimage options that exist:

  • -visible boolean — a boolean that decides whether the dragimage should currently be visible. That's it, that's the whole option. 🦋
  • pathName dragimage offset ?x y? — no extra args? You get a list with the x and y offsets of the dragimage. The dragimage offset is the screen distance the image is displayed at relative to the item(s) its shape is derived from. 📏 Pass two coordinates and it sets the dragimage offset to those x and y values instead.

pathName element option ?element? ?arg arg ...?

This is the one for manipulating elements (go read ELEMENTS AND STYLES below, bestie, it's important 📖). What happens depends on the option that follows element. Supported forms:

  • pathName element cget element option — returns the current value of the option named option associated with the element given by element. option can be any of the values accepted by the element configure widget command.

This command also accepts the -statedomain option. ✨

  • pathName element configure element ?option? ?value? ?option value ...? — same as the configure widget command, except it modifies options associated with the element given by element rather than options for the overall treectrl widget.
    • No option? You get a list describing all available options for element (yes, Tk_ConfigureInfo, you know the drill).
    • option with no value? A list describing that one named option, identical to the corresponding sublist from the no-option result.
    • One or more option-value pairs? It sets those option(s) to those value(s) in element and returns an empty string.
    • Head down to ELEMENTS AND STYLES below for the details on which options elements actually have. 🌈

🫶 pathName element create

pathName element create name type ?option value ...?

okay so this makes a brand new master element of type type, gives it the unique user-defined name name, and configures it with zero or more option/value pairs. Which options are even valid? Depends on the type, bestie — go read the subsections on individual element types in ELEMENTS AND STYLES. ✨

It hands you back the name of the new element (literally the same as the name argument, so no surprises 💅).

Oh and plot twist — this command ALSO accepts the -statedomain option, with a value of either header or item, to specify where this element will be displayed. 🎀


🌸 pathName element delete

pathName element delete ?element ...?

Deletes each of the named elements and returns an empty string. But listen — if an element gets deleted while it's still configured as an element of one or more styles (via the style elements widget command), it also gets removed from the element lists of those styles. Cleanup queen. 🧹✨


🦋 pathName element names

Returns a list containing the names of all existing elements. That's it, that's the whole vibe check. 👑


💜 pathName element perstate

pathName element perstate element option stateList

This one returns the value of the per-state option named option for element, for a certain state. stateList is a list of state names (static AND dynamic, see STATES) which specifies the state to use. 🎀


⭐ pathName element type

pathName element type element

Returns the type of the element given by element — like rect or text. iykyk. 💅


😭 pathName expand

pathName expand ?-recurse? ?itemDesc ...?
Deprecated. Use item expand instead. fr fr, don't be out here using the old one. 🙈

🌈 pathName gradient

pathName gradient option ?arg ...?

This command is your whole gradient manipulation station 💖 — see GRADIENTS for more info about using gradients. The exact behavior depends on the option argument that follows the gradient argument. Here's every supported form:


💅 pathName gradient cget

pathName gradient cget gradient option

Returns the current value of the configuration option for the gradient specified by gradient whose name is option. And option may have any of the values accepted by the gradient configure command. No cap. ✨


🎀 pathName gradient configure

pathName gradient configure gradient ?option value ...?
  • If no option is specified, the command returns a list describing all of the available gradient options (see Tk_ConfigureInfo for the format of this list).
  • If option is specified with no value, it returns a list describing that one named gradient option (this list will be identical to the corresponding sublist of the value returned if no option is specified).
  • If one or more option-value pairs are specified, then the command modifies the given gradient option(s) to have the given value(s) — and in that case it returns an empty string.

The following options are supported (see gradient create for the meaning of each one):

  • -bottom coordSpec
  • -left coordSpec
  • -orient direction
  • -right coordSpec
  • -steps stepCount
  • -stops stopsList
  • -top coordSpec

🦋 pathName gradient create

pathName gradient create name ?option value ...?

Creates a new gradient with the name name, which has to be a unique name not used by another gradient created by this treectrl widget. Main character names only, bestie. 👑

The following options are supported:

  • -bottom coordSpec, -left coordSpec, -right coordSpec, -top coordSpec — each of these options specifies one edge of the gradient brush. If the option is specified as an empty string (the default), the gradient brush's edge is the same as that of whatever rectangle is being painted using the gradient. See GRADIENT COORDINATES for the details on gradient brush coordinates.

The format of each of these options is a list of 2 or more values {value coordType ?arg ...?}, where value is a floating point number (usually from 0.0 to 1.0) and coordType is one of area, canvas, column or item. The area keyword must be followed by one of the same area names that the bbox command accepts. The column keyword may be followed by a column description specifying exactly one column. The item keyword may be followed by an item description specifying exactly one item. ✨

  • -orient direction — this option specifies the direction a linear gradient changes color in. Must be either horizontal (the default) or vertical, or an abbreviation of one of these.
  • -steps stepCount — specifies the number of bands of color drawn for each color stop described by the -stops option. The default value is 1, the maximum is 25. Heads up: this option has no effect if gradients are drawn using something better than Tk API calls. See GRADIENTS for more on this. 💀
  • -stops stopsList — specifies the color stops along this gradient. The argument stopsList has the following form:
{{offset color ?opacity?} {offset color ?opacity?} ...}

Each offset is a floating point number from 0.0 to 1.0 specifying the distance from the start of the gradient where the color begins. Each color is a Tk color name or description. Each optional opacity is a floating point number from 0.0 to 1.0 specifying how transparent the gradient is.

If stopsList is non-empty there must be at least two stops specified, and the first offset must be 0.0 and the last offset must be 1.0. Any other stop offsets must be listed in increasing order. Specifying opacity has no effect if gradients are drawn using Tk API calls. See GRADIENTS for more on this. 🌈


🔥 pathName gradient delete

pathName gradient delete ?name ...?

Deletes each gradient specified by name. But wait — if the gradient is still being used, then it is not actually deleted until all elements etc. using the gradient have stopped using it. And a deleted-but-in-use gradient is not recognized by the various gradient commands. Plot twist tho: creating a new gradient with the same name as a deleted-but-in-use gradient resurrects the deleted gradient. iconic behavior honestly 💅✨


🍓 pathName gradient names

Returns a list of names of all the gradients that have been created by this treectrl widget. The roster, if you will. 📋


💖 pathName gradient native

pathName gradient native ?preference?

With no arguments at all, this command returns a boolean indicating whether or not the platform supports native transparent gradients. The preference argument is a boolean that indicates whether native gradients should be used — handy for testing out the appearance of the application. 🎀


🌸 pathName header

pathName header option ?arg ...?

This command is used to manipulate column headers. The exact behavior depends on the option argument that follows the header argument. The following forms of the command are supported:


🦋 pathName header bbox

pathName header bbox headerDesc ?column? ?element?

See the item bbox command. (Same energy, different domain, bestie. ✨)


⭐ pathName header compare

pathName header compare headerDesc1 op headerDesc2

See the item compare command. 👑


💜 pathName header configure

pathName header configure headerDesc ?arg ...?

There are two forms of this command, and what tells them apart is whether or not a column description appears after the headerDesc argument:

  • If the first argument after headerDesc begins with a - character, it's assumed to be an option name, not a column description — in which case the command applies to the header-row.
  • If the first argument after headerDesc does not begin with a -, it's assumed to be a column description — in which case the command applies to a header-column.

🎀 pathName header configure headerDesc ?option? ?value? ?option value ...?

  • If no option is specified, it returns a list describing all of the available options for the header given by headerDesc (see Tk_ConfigureInfo for information on the format of this list).
  • If option is specified with no value, then the command returns a list describing that one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified).
  • If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s) — and in this case the command returns an empty string. Heads up: this is the only case where headerDesc may refer to multiple header-rows. 🚨

The following options are supported by this command (see header create for the meaning of each option):

  • -height height
  • -tags tagList
  • -visible boolean

pathName header configure headerDesc column ?option? ?value? ?option value ...?

okay bestie, so if you pass no option, you get back a whole list describing all the available options for that single column (column) of the header-row given by headerDesc — check Tk_ConfigureInfo if you wanna know the format of that list, that's where it's defined fr.

If you give an option but no value? Then you get a list describing just that one named option, and lowkey it's identical to the matching sublist of what you'd get back with no option at all. cute.

And if you hand over one or more option-value pairs, the command modifies those option(s) to have the value(s) you gave. In that case it returns an empty string 💅. And heads up — this is the only case where headerDesc can refer to multiple header-rows and column can refer to multiple header-columns. iconic behaviour honestly.

These are the options this command supports (peep the HEADERS section for what each one actually means):

  • -arrow direction
  • -arrowbitmap bitmap
  • -arrowgravity direction
  • -arrowimage image
  • -arrowpadx amount
  • -arrowpady amount
  • -arrowside side
  • -background color
  • -bitmap bitmap
  • -borderwidth size
  • -button boolean
  • -font fontName
  • -image image
  • -imagepadx amount
  • -imagepady amount
  • -justify justification
  • -state state
  • -text text
  • -textcolor color
  • -textlines count
  • -textpadx amount
  • -textpady amount

pathName header count ?headerDesc?

No extra args? Then you get a decimal string — the number of header-rows made by the header create widget command that haven't been deleted by header delete, plus 1 for the ever-present top header-row that got created along with the widget itself 🎀.

But if you do pass the optional headerDesc, then you get the number of header-rows that match that header description. simple as.


pathName header create ?option value?

Creates a new header-row and hands you back its unique identifier ✨. These are the config options it supports:

  • -height height — sets a fixed height for the header-row, in any form that Tk_GetPixels will accept. Must be >= 0. If height is zero, then the header-row's height is the maximum height of all of its column headers. Defaults to 0.
  • -tags tagList — tagList is a list of tag names to be added to the new header-row. You can also use the header tag command to manipulate this list of tags.
  • -visible boolean — boolean must be one of the forms accepted by Tcl_GetBoolean. It says whether or not the header-row should be displayed. And ngl, if the widget option -showheader is false, then the header-row won't be displayed regardless of what you put here. periodt.

pathName header delete headerDesc

Deletes the header-rows given by the header description headerDesc. And oop — if you try to delete the ever-present top header-row, those attempts are ignored without raising an error. no drama, no 💀.


pathName header dragcget ?arg ...?

There are two forms of this command, and which one you get depends on whether a header description shows up as the first argument. Here's the vibe check: if the first argument starts with a - character, it's assumed to be an option name, not a header description — so the command applies to the header-drag-and-drop options for the widget. If the first argument does not start with a -, it's assumed to be a header description — so the command applies to a header-row.

pathName header dragcget option

Returns the current value of the header-drag-and-drop option named option for the widget. These are the config options it supports (peep header dragconfigure for what each one means):

  • -enable boolean
  • -imagealpha alpha
  • -imagecolor background
  • -imagecolumn column
  • -imageoffset offset
  • -imagespan count
  • -indicatorcolor color
  • -indicatorcolumn column
  • -indicatorside side
  • -indicatorspan count

pathName header dragcget headerDesc option

Returns the current value of the header-drag-and-drop option named option for a header-row. These are the config options it supports (again, header dragconfigure explains each one):

  • -draw boolean
  • -enable boolean

pathName header dragconfigure ?arg ...?

Same deal, two forms, distinguished by whether a header description appears as the first argument. First arg starts with -? Then it's an option name, not a header description, and the command applies to the header-drag-and-drop options for the widget. First arg doesn't start with -? Then it's a header description, and the command applies to a header-row. iykyk.

pathName header dragconfigure ?option? ?value? ?option value ...?

This one queries and sets header-drag-and-drop options for the widget, not for individual header-rows. Supported config options:

  • -enable boolean — controls whether the user is allowed to rearrange columns by drag-and-drop. Default is false. Every header-row also has its own -enable dragconfigure option, so don't get them confused bestie.
  • -imagealpha alpha — alpha is an integer from 0 (invisible) to 255 (opaque) controlling the transparency of the drag image. Any value outside this range is clipped. Default is 200.
  • -imagecolor background — unused.
  • -imagecolumn column — column specifies the column to create the drag image from.
  • -imageoffset offset — offset is the horizontal screen distance the drag image is offset from its starting position.
  • -imagespan count — count is the number of columns, starting with -imagecolumn, that will be dragged as a group.
  • -indicatorcolor color — unused.
  • -indicatorcolumn column — the 2-pixel-thick line will be drawn over the left or right edge of column.
  • -indicatorside side — unused.
  • -indicatorspan count — count is the number of columns, starting with -indicatorcolumn, that will be displaced as a group by the dragged column(s).

pathName header dragconfigure header ?option? ?value? ?option value ...?

This one queries and sets header-drag-and-drop options for header-rows, not for the widget as a whole. Supported config options:

  • -draw boolean — controls whether a header-row displays any feedback during header drag-and-drop. Default is true.
  • -enable boolean — controls whether clicking and dragging in this header-row initiates drag-and-drop. Default is true. But if the -enable option for the widget is false (see above), then this option has no effect. so yeah, widget says no, header-row's opinion doesn't matter 💅.

pathName header element ?arg ...?

Just go look at the item element command, bestie — it's the same energy. 🦋


pathName header id headerDesc

This command resolves the header description headerDesc into a list of unique header-row identifiers. And if headerDesc doesn't refer to any existing header-rows? Then you just get an empty list back. no cap. 🙈

pathName header image

pathName header image headerDesc ?column? ?image? ?column image ...?

okay so this one’s a lil conditional 💅. Its behavior depends on whether or not a column header was assigned a style containing an image element. If a column header has no style or no style with an image element then this command operates on the same -image option as header configure. Otherwise this command operates on the -image option of the first image element in a column header's style. See the item image command for the deets. ✨


pathName header span

pathName header span headerDesc ?column? ?numColumns? ?column numColumns ...?

See the item span command. That’s it, bestie. 🎀


pathName header state

pathName header state command headerDesc ?arg ...?

See the item state command. Go peep that. 💖


pathName header style

pathName header style command headerDesc ?arg ...?

See the item style command. It’s giving item style. 🦋


pathName header text

pathName header text headerDesc ?column? ?text? ?column text ...?

The behavior of this command depends on whether or not a column header was assigned a style containing a text element. If a column header has no style or no style with a text element then this command operates on the same -text option as header configure. Otherwise this command operates on the -text option of the first text element in a column header's style. See item text. 🌸


pathName header tag

pathName header tag command headerDesc ?arg ...?

See the item tag command. fr fr. 💅


pathName identify

pathName identify ?-array varName? x y

This command returns information about what is displayed at the given window coordinates x and y. When the -array option is used to specify the name of an array variable, elements of the array variable are set as follows:

  1. If the coordinates are outside the window, over the borders, or over any whitespace in the window, then:
    • $varName(where) is ""
  2. If the coordinates are over a column header, then:
    • $varName(where) is header
    • $varName(header) is the unique id of the header-row
    • $varName(column) is the unique id of the column
    • $varName(element) is the name of an element, or ""
    • $varName(side) is left or right if the coordinates are close to the edge of the column header, otherwise ""
  3. If the coordinates are over an item, then:
    • $varName(where) is item
    • $varName(item) is the unique id of the item
    • $varName(column) is the unique id of the column
    • $varName(element) is the name of an element, or ""
    • $varName(button) is a boolean indicating whether or not the coordinates are over the item's expand/collapse button
    • $varName(line) is the unique id of an ancestor of the item (but not the parent of the item) if the coordinates are over a line descending from that ancestor. If the coordinates are not over such a line then $varName(line) is "". This is used to collapse the ancestor when the line is clicked on.

When the -array option is not used, this command returns a list describing what is displayed at the given window coordinates. The format of this list can be like one of the following:

  1. {} An empty list is returned if the coordinates are outside the window, over the borders, or over any whitespace in the window.
  2. header C ?left|right? header C elem E ?left|right? header H column C ?left|right? header H column C elem E ?left|right? Only when there is more than one header-row is there a unique id of a header-row H followed by the keyword column. This is for compatibility with older versions when there was only one row of column headers allowed.
  3. item I column C
  4. item I column C elem E
  5. item I button This is the result when the coordinates are over the expand/collapse button next to an item.
  6. item I line I2 This is the result when the coordinates are over a line descending from an ancestor I2 of the item I (but not the parent of that item). This is used to collapse the ancestor when the line is clicked on.

pathName index

pathName index itemDesc

Deprecated. Use item id instead. 💅


pathName item

pathName item option ?arg ...?

This command is used to manipulate items. The exact behavior of the command depends on the option argument that follows the item argument. The following forms of the command are supported:

pathName item ancestors

pathName item ancestors itemDesc

Returns a list containing the item ids of the ancestors of the item specified by itemDesc. The first list value is the parent, the second is the parent's parent, and so on. The last list value will be the root item if itemDesc is a descendant of the root item. 🌳

pathName item bbox

pathName item bbox itemDesc ?column? ?element?

Returns a list with four elements giving the bounding box of the item described by itemDesc. If no further argument is specified, the bbox spans the area of the item over all non-locked columns. If a column is specified, only the area of the item in this column is considered. If an additional element is specified, the area of this element in column of the specified item is returned. The returned coordinates are relative to the top-left corner of the widget. If the item is not visible for any reason, the result is an empty string. 📦

pathName item buttonstate

pathName item buttonstate itemDesc ?state?

If state is specified, this command sets the state of the expand/collapse button for the single item specified by itemDesc. The state argument may be one of active, normal or pressed. The current (or newly-set) state of the button is returned. The button state is used by the system theme, if any, to change the appearance of the button. 🔘

pathName item cget

pathName item cget itemDesc option

Returns the current value of the configuration option for the item specified by itemDesc whose name is option. Option may have any of the values accepted by the item configure command. 🔍

pathName item children

pathName item children itemDesc

Returns a list containing the item ids of all children of the item specified by itemDesc in the correct order from the first child to the last child. 👶👧🧑

pathName item collapse

pathName item collapse itemDesc ?-animate? ?-recurse?

Switches off the open state of the item(s) described by itemDesc. If an item has descendants, then they are no longer displayed. If an item is already closed, then this command has no effect on that item. If -animate is specified, then the item's button will animate as it transitions between states if the theme supports it; in this case only one item may be specified. If -recurse is specified, then all descendants of the items described by itemDesc will also be collapsed. For every item that actually will be collapsed, two events are generated: a <Collapse-before> event before the item state is changed, and a <Collapse-after> event after the item state was changed. 😭💔

pathName item compare

pathName item compare itemDesc1 op itemDesc2

From both items described by the itemDescs the index is retrieved (as returned from the item order widget command). Then these indexes are compared using the operator op, which must be either <, <=, ==, >=, >, or !=. The return value of this command is 1 if the comparison evaluated to true, 0 otherwise. ⚖️

pathName item complex

pathName item complex itemDesc ?list...?

This horrible command is now deprecated. Use item element configure instead. For every column of the treectrl there may be specified one list. Each list should look like this:

{ {element option value ...} {element option value ...} ...}

Every option must be known by the element's type (see ELEMENTS AND STYLES below). Each option will be set to value for the element in this one column in this item. 💀

pathName item configure

pathName item configure itemDesc ?option? ?value? ?option value ...?

If no option is specified, returns a list describing all of the available options for the item given by itemDesc (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified).

If one or more option-value pairs are specified, then the command modifies the given item option(s) to have the given value(s); in this case the command returns an empty string. This is the only case where itemDesc may refer to multiple items.

The following options are supported by this command (see item create for the meaning of each option):

  • -button boolean|auto
  • -height height
  • -tags tagList
  • -visible boolean
  • -wrap boolean

pathName item count

pathName item count ?itemDesc?

If no additional arguments are given, the result is a decimal string giving the number of items created by the item create widget command which haven't been deleted by the item delete widget command, plus 1 for the ever-present root item. If the optional argument itemDesc is given, then the result is the number of items that match that item description. 🔢


✨ pathName item create ?option value ...? ✨

okay bestie, this is THE one — the command that actually makes items 💖 It creates some new items and optionally hands you back a list of unique identifiers for those items.

The new items come with the states open and enabled set by default. And here's a cute lil detail — if the treectrl widget currently has the focus, the state focus is also set. main character energy from the literal moment of birth, we love to see it 👑

The following options are supported by this command:

  • -button boolean|auto — the value here has to be one of the forms accepted by Tcl_GetBoolean, or the word auto (or any abbreviation of it — go off, shorthand queen). It says whether or not an expand/collapse button should be drawn next to the item, typically to signal "hey, this one has children 👀". If the value is auto, then a button gets displayed next to the item whenever that item has any children whose item option -visible is true.

The button will only be displayed if:

  1. the column specified by the treectrl option -treecolumn is visible, and
  2. the treectrl option -showbuttons is true, and
  3. for the root item, the treectrl option -showrootbutton is true, and
  4. for immediate children of the root item, the treectrl option -showrootchildbuttons is true.

yeah it's a whole checklist. four gates. the button does not simply appear, it auditions 💅

  • -count numItems — specifies the number of items to create. Must be >= 0. Defaults to 1.
  • -enabled boolean — specifies whether the items should be enabled. Default is true.
  • -height height — specifies a fixed height, in any of the forms acceptable to Tk_GetPixels. Must be >= 0. If height is zero then the item's height is unspecified. Defaults to 0. See also the widget options -itemheight and -minitemheight.
  • -nextsibling itemDesc — specifies the item before which the new items will be inserted. The new items will have the same parent as itemDesc.
  • -open boolean — specifies whether the items should be open or closed. Default is true.
  • -parent itemDesc — specifies the item which the new items will be the children of. The new items will be appended to the list of children of itemDesc. When no parent is specified, the new items are orphan items (see the widget command orphans) and will not be displayed in the list. sad little ghost items, no cap 😭
  • -prevsibling itemDesc — specifies the item after which the new items will be inserted. The new items will have the same parent as itemDesc.
  • -returnid boolean — specifies whether or not to return a list of item identifiers for the newly created items. Specifying false is useful when creating a large number of items in the console, or to improve performance. Default is true.
  • -tags tagList — tagList is a list of tag names to be added to the new items. The item tag command can also be used to manipulate this list of tags.
  • -visible boolean — boolean must have one of the forms accepted by Tcl_GetBoolean. It indicates that the item should be displayed in the list.

The item will only be displayed if:

  1. each ancestor is a descendant of the root item (not an orphan), and
  2. each ancestor's -visible option is true
  • -wrap boolean — boolean must have one of the forms accepted by Tcl_GetBoolean. It indicates that this item should be the first one in a horizontal range or vertical range of items. See also the widget option -wrap.

🌸 pathName item delete first ?last? 🌸

Deletes the specified item(s) 💀 First and last must be valid item descriptions.

If last isn't specified, then first may specify multiple items. If both first and last are specified, they must each describe a single item with a common ancestor; then the range of items between first and last is deleted. And plot twist — the order of first and last doesn't matter. write it however you want bestie, it's chill.

Deleting an item deletes any child items of the deleted item recursively. so like. the whole bloodline goes. it's giving generational 💅

If the current active item is deleted, the root item becomes the new active item. If the current selection anchor item is deleted, the root item becomes the new anchor item.

🚨 There is no way to delete the root item of the treectrl widget; in all cases the specification of the root item is ignored. the root is eternal, the root is forever, periodt 👑

For each call to this command, two events may be generated:

  • If any of the deleted items are selected, then they are removed from the selection and a <Selection> event is generated just before the items are deleted.
  • If any items are going to be deleted, then an <ItemDelete> event is generated just before the items are deleted.

🦋 pathName item descendants itemDesc 🦋

Returns a list containing the item ids of the descendants of the item specified by itemDesc — i.e. the children, grandchildren, great-grandchildren etc, of the item. the whole family tree, everyone's invited 🌈


💅 pathName item dump itemDesc 💅

Debug command. Returns a list with 4 words in the form index index indexVis indexVis. very mysterious, very "i'm a debug command and i know things" 🙈


🎀 pathName item element command itemDesc column element ?arg ...? 🎀

This command is used to manipulate elements of the item. The exact behavior of the command depends on the command argument that follows the element argument. The following forms of the command are supported:

pathName item element actual itemDesc column element option

Deprecated. Use item element perstate instead. we don't do this anymore bestie, it's giving 2012

pathName item element cget itemDesc column element option

This command returns the value of the option named option associated with element inside column of the item described by itemDesc, if it was already configured for the actual item. Option may have any of the values accepted by the type of the specified element (see ELEMENTS AND STYLES below).

pathName item element configure itemDesc column element ?option? ?value? ?option value ...?

This command modifies configuration options for an element in a column of an item.

  • If no option is specified, the command returns a list describing all of the available options for the element (see Tk_ConfigureInfo for information on the format of this list).
  • If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified).
  • If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s) in the element inside column of the item(s) described by itemDesc; in this case the command returns an empty string.

This is the only case where itemDesc may refer to multiple items. glow up moment ✨

It is possible to configure multiple elements in multiple columns with a single call:

  • To configure another element in the same column, append a + argument followed by the element name.
  • To configure elements in another column, append a , argument followed by the column.

For example:

$C1 $E1 -text "hello" + $E2 -text "world" , \
$C2 $E3 -fill Blue , \
$C3 $E1 -text "apples and oranges"

Each of the column description arguments to this command may refer to multiple columns if at least one option-value pair is given.

pathName item element perstate itemDesc column element option ?stateList?

This command returns the current value of the per-state option named option for element inside column of the item described by itemDesc. If stateList is specified, the list of state names (static and dynamic, see STATES) is used in place of the current state for item and column.


⭐ pathName item enabled itemDesc ?boolean? ⭐

Returns 1 if the item described by itemDesc has the state enabled switched on, 0 otherwise.

If boolean is specified, then the enabled state of every item described by the item description itemDesc is set accordingly.

New items are enabled by default when created. Disabled items cannot be selected, and are ignored by the default key-navigation and mouse bindings. so like… if you disable something, don't act surprised when it ignores you 🙈 the boundaries are set, babe.

pathName item expand itemDesc ?-animate? ?-recurse?

Okay bestie, this one flips the open state of the item(s) that itemDesc points at. If an item has descendants, they're now on display ✨. And if an item is already open? Then this command just… does nothing to it. No drama, no effect, we move on 💅.

If you pass -animate, the item's button will animate as it transitions between states — but only if the theme supports it. Heads up though: with -animate you can only specify one item. One. Singular. Don't be greedy 🫶.

If you pass -recurse, then all descendants of the items in itemDesc get expanded too, chain reaction style.

And for every item that actually will be expanded, two events fire off:

  • an <Expand-before> event before the item state changes
  • an <Expand-after> event after the item state was changed

Periodt. 👑


pathName item firstchild parent ?child?

No child? Then you get the item id of the first child of whatever parent describes. Simple, cute.

But if child is specified, it has to describe an item that is neither the root item nor an ancestor of parent. Then it becomes the new first child of parent. Slay, moving up in the world 🦋.


pathName item id itemDesc

This resolves the item description itemDesc into a list of unique item identifiers 💖. And if itemDesc doesn't refer to any existing items at all? You get an empty list back. Nothing. Void. The silence of the group chat 😭.


pathName item image itemDesc ?column? ?image? ?column image ...?

This sets or retrieves the value of the per-state -image option for the first image element in one or more columns.

  • No column given → you get a list of values, one per column.
  • No image given → you get the value for column.

Now, if you pass one or more column image pairs, then the -image option in each column gets set to image. In that case itemDesc may refer to multiple items, and each column may refer to multiple columns 🌈.

Ngl, this command is literally just a convenience. If you want to set or retrieve the -image option for a specific image element, go use the item element configure or item element cget commands instead. iykyk 💅

pathName item isancestor itemDesc descendant

Returns 1 if the item described by itemDesc is a direct or indirect parent of the item described by descendant, and 0 otherwise. Yes/no energy only 🎀.


pathName item isopen itemDesc

Returns 1 if the item described by itemDesc has the state open switched on, 0 otherwise. Vibe check: are you open or are you closed 🙈.


pathName item lastchild parent ?child?

No child? You get the item id of the last child of the item described by parent.

If child is specified, it must describe an item that is not an ancestor of parent. Then it becomes the new last child of parent. Saving the best for last, iconic ✨.


pathName item nextsibling sibling ?next?

No next? You get the item id of the next sibling of the item described by sibling.

If next is specified, it must describe an item that is not an ancestor of sibling. Then it becomes the new next sibling of sibling 💜.


pathName item numchildren itemDesc

Returns the number of children of the item described by itemDesc. Counting the children, no cap 🔢.


pathName item order itemDesc ?-visible?

This returns the position of itemDesc relative to its toplevel ancestor — usually the root item, unless that ancestor is an orphan. Picture all the items flattened into one big vertical list: the result of this command is the row the item falls in 📋.

If you hand it the optional -visible argument, only items whose ancestors are expanded and whose -visible option is true get counted. And in that case, -1 is returned if the item is not visible. Ghosted, fr fr 👻.


pathName item parent itemDesc

Returns the item id of the parent of the item described by itemDesc. Family tree, but make it lookup 🌸.


pathName item prevsibling sibling ?prev?

No prev? You get the item id of the previous sibling of the item described by sibling.

If prev is specified, it must describe an item that is not an ancestor of sibling. Then it becomes the new previous sibling of sibling 🧚.


pathName item range first last

Returns a list containing the item ids of all items in the range between first and last, inclusive 💖.

The order between first and last doesn't matter — the result is always sorted by increasing order of the items, as returned by the item order command. And the items specified by first and last must share a common ancestor. Family reunion rules 🫶.


pathName item remove itemDesc

Removes the item described by itemDesc from the list of children of its parent, so that it becomes an orphan. Okay not me making it an orphan 😭 that's just what the command does bestie.


pathName item rnc itemDesc

Returns a list of two integers, which corresponds to the row and column of the item described by itemDesc 📍. The row and column correspond to the on-screen arrangement of items as determined by the -orient and -wrap options. If the item is not displayed, this command returns an empty string. Nothing. Nowhere. Lost to the void 💀.


pathName item sort itemDesc ?option ...?

Sorts the children of the item described by itemDesc, and redisplays the tree with the items in the new order. Glow-up moment 🔥.

The range of items that gets sorted can be restricted using the -first and/or -last options, which should be children of the item described by itemDesc. The order between these two limiting items doesn't matter ✨.

The sort column can be specified with the -column option, and you can use this option repeatedly to define a multicolumn sort 👑. The sorting works by looking at the text of the element specified by the -element option, which must be a text element defined in the style of the sorting column — by default the first text element is used.

If you specify -notreally, no rearranging of the items happens at all. Instead the sorted items are returned as the result of the command. All the sorting, none of the commitment 💅.

By default, ASCII sorting is used with the result returned in increasing order. Any of the following options may be specified to control the sorting process of the previously specified column (unique abbreviations are accepted):

  • -ascii — Use string comparison with ASCII collation order. This is the default.
  • -command command — Use command as a comparison command. To compare two items, evaluate a Tcl script consisting of command with the numerical ids of the two items appended as additional arguments. The script should return an integer less than, equal to, or greater than zero if the first item is to be considered less than, equal to, or greater than the second, respectively.
  • -decreasing — Sort the items in decreasing order ("largest" items first).
  • -dictionary — Use dictionary-style comparison. 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.
  • -increasing — Sort the items in increasing order ("smallest" items first). This is the default.
  • -integer — Convert to integers and use integer comparison.
  • -real — Convert to floating-point values and use floating comparison.

pathName item span itemDesc ?column? ?numColumns? ?column numColumns ...?

This command sets or retrieves the number of columns that a style covers 🌈.

  • No column specified → the return value is a list of spans, one per column.
  • No numColumns specified → the return value is the span for column.

If one or more column numColumns pairs are specified, the span for each column is set to numColumns. In this case itemDesc may refer to multiple items, and each column may refer to multiple columns 💖.


pathName item state command itemDesc ?arg ...?

This command is used to manipulate the states of an item. The exact behavior depends on the command argument that follows the style argument. The following forms of the command are supported:

pathName item state define stateName

Defines a new state with the name stateName, which must not be the name of an existing state. Brand new, no duplicates allowed 🎀.

pathName item state forcolumn itemDesc column ?stateDescList?

Just like item state set but manipulates dynamic states for a single item column, not the item as a whole 🦋. If stateDescList is unspecified, this command returns a list containing the names of all the dynamic states which are switched on in column.

If stateDescList is specified, then itemDesc may refer to multiple items and column may refer to multiple columns. Multi-tasking queen 👑.

  • pathName item state get itemDesc ?stateName? — no stateName? you get a list of every state (static and dynamic) that's currently switched on for the item in itemDesc. pass a stateName and it's a straight yes/no vibe check: 1 if that state is switched on for the item right now, 0 if it isn't. 💅
  • pathName item state linkage stateName — returns a string telling you whether the state is user-defined (made with the item state define widget command → that's the dynamic situation) or predefined by the treectrl widget itself (→ static). 🔍
  • pathName item state names — hands you a list of every user-defined state name. that's it, that's the whole thing. ✨
  • pathName item state set itemDesc ?lastItem? stateDescList — every element of stateDescList has to be the name of a dynamic state (go peep STATES below), optionally with a ~ or ! in front. Leading ! → that state gets switched off for the item in itemDesc. Leading ~ → it gets toggled. No leading ! or ~ → it gets switched on. Give it a lastItem and the changes happen for every item in the range between itemDesc and lastItem. No lastItem? then the changes land on all items described by itemDesc. 🎚️
  • pathName item state undefine ?stateName ...? — every stateName has to be a user-defined state. this removes it from the list of user-defined states. bye bestie 👋

pathName item style command itemDesc ?arg ...?

Your whole style-manipulation station for items. what it actually does depends on the command argument sitting right after style. these are the supported forms:

  • pathName item style elements itemDesc column — returns a list of the element names that were configured by the item element configure command for the item in itemDesc in column. no style assigned to column? error, sorry bestie. 😭
  • pathName item style map itemDesc column style map — kinda like item style set, this assigns a style to one specific column of an item. but unlike item style set, it can transfer configuration values from elements in the current style over to elements in the new style named by style. map must be a list of elementOld-elementNew pairs, where elementOld is an element in the current style and elementNew is an element in the style specified by style. both elementOld and elementNew must be the same type (bitmap, text, etc). itemDesc can refer to multiple items and column can refer to multiple columns. 🗺️
  • pathName item style set itemDesc ?column? ?style? ?column style ...? — sets or retrieves the style assigned to one or more columns.
    • no column? you get a list containing the style names set for all columns of the item in itemDesc.
    • no style? you get the name of the style set for the item in itemDesc in column.
    • one or more column-style pairs? then the style in each column gets set to style. in this case itemDesc may refer to multiple items and each column may refer to multiple columns. 🎨

pathName item tag option ?arg arg ...?

Tag-manipulation central. the exact behavior depends on the option argument that comes after item tag. supported forms:

  • pathName item tag add itemDesc tagList — adds every tag in tagList to the items in itemDesc. duplicate tags are ignored, zero drama. you can also change an item's tag list through its -tags option. 🏷️
  • pathName item tag expr itemDesc tagExpr — evaluates the tag expression tagExpr against every item in itemDesc. result is 1 if the expression comes out true for every item, 0 otherwise. 🧮
  • pathName item tag names itemDesc — returns a list of tag names assigned to the items in itemDesc. the result is the union of any tags assigned to the items. 🤝
  • pathName item tag remove itemDesc tagList — removes every tag in tagList from the items in itemDesc. not an error if any of the items don't use any of the tags, so no need to stress. you can also change an item's tag list via its -tags option. 🧹

pathName item text itemDesc ?column? ?text? ?column text ...?

Sets or retrieves the value of the -text option for the first text element in one or more columns.

  • no column? returns a list of values, one per column.
  • no text? returns the value for column.
  • one or more column-text pairs? then the value of -text in each column gets set to text. in that case itemDesc may refer to multiple items and each column may refer to multiple columns.
ngl this command is purely a convenience. if you want to set or retrieve the -text option for a specific text element, use item element configure or item element cget instead. 💖

pathName item toggle itemDesc ?-animate? ?-recurse?

Flips the open state of the item(s) described by itemDesc. if open is currently switched off, this does the same as the item expand widget command; otherwise it does the same as the item collapse widget command.

  • -animate — the item's button animates as it transitions between states, if the theme supports it. careful tho: in this case only one item may be specified. ✨
  • -recurse — the open state of all descendants of the items described by itemDesc also gets toggled. 🌳

pathName marquee option ?arg ...?

Marquee time 🎀 this one manipulates the marquee, which is how you'd implement a resizable selection rectangle — a file browser, for example. one corner point of the marquee stays fixed as long as the marquee is visible, and it's called the anchor; the diagonally opposite corner gets dragged with the mouse while you're resizing it and is simply called the corner.

Every coordinate this widget command handles is a canvas coordinate — so use the canvasx or canvasy widget command to translate window coordinates into canvas coordinates.

By default, the marquee shows up as a 1-pixel thick dotted rectangle. if either the -fill or -outline option is specified, then the marquee gets drawn as a filled and/or outlined rectangle in the given color(s). the -fill option should specify a transparent gradient so it doesn't hide whatever's inside the marquee. peep GRADIENTS for more info. 🌈

The exact behavior of the command depends on the option argument that follows marquee. supported forms:

  • pathName marquee anchor ?x y? — no additional arguments? you get a list containing the x and y coordinates of the anchor. two coordinates specified? sets the anchor to the given coordinates x and y. 📍
  • pathName marquee cget option — returns the current value of the marquee option named option. option can be any of the values accepted by the marquee configure widget command. 🔎
  • pathName marquee configure ?option? ?value? ?option value ...? — same energy as the configure widget command, except it modifies the marquee options instead of the options for the overall treectrl widget.
    • no option? returns a list describing all of the available marquee options (see Tk_ConfigureInfo for info on the format of this list).
    • option with no value? returns a list describing that one named marquee option — identical to the corresponding sublist of the value you'd get with no option.
    • one or more option-value pairs? modifies the given marquee option(s) to have the given value(s), and in this case the command returns an empty string.

The following marquee options are supported:

  • -fill color — specifies the color to fill the marquee rectangle with. (see the comments above about using a transparent gradient here 💅)
  • -outline color — the colour the marquee rectangle gets outlined in. Your little drag-box glow-up 💅
  • -outlinewidth color — yep, the name literally says "color", but bestie it's the width of the outline drawn inside the marquee's rectangle. If this value is less than 1, no outline is drawn at all, periodt. And heads up: this option does nothing if -outline is unspecified — i.e. the default dotted rectangle is completely unaffected by it. outlineWidth can be in any of the forms Tk_GetPixels accepts. Defaults to 1.
  • -visible boolean — a boolean that decides whether the marquee is displayed or just vibing invisibly. 🫥

pathName marquee coords ?x1 y1 x2 y2?

Called with no extra args, it hands you a list with the x and y coords of the anchor, followed by the x and y coords of the corner. Give it four coordinates and it sets the anchor to x1/y1 and the corner to x2/y2. ✨

pathName marquee corner ?x y?

No extra args? You get a list with the x and y coordinates of the corner. Pass two coordinates and it sets the corner to x and y. Simple as. 🎀

pathName marquee identify

Returns a list stuffed with info about every item intersecting the marquee. The format of that returned list is:

{
    {item {column element element ...} {column element element ...} ...}
    {item {column element element ...} {column element element ...} ...}
    ...
}

Okay so, real talk: there may be zero sublists following an item id if the marquee is chilling in the button/line area of an item. And there may be zero element names following a column id if the item-column has no style, or if the marquee doesn't intersect any elements in that column. No cap. 💀


pathName notify option ?arg ...?

Many Tk widgets talk to the outside world through -command callbacks and/or virtual events. Like, the Text widget evaluates its -yscrollcommand when the view changes, and fires off a <<Modified>> virtual event when text gets inserted or deleted. But a treectrl widget? It replaces both of those methods of communication with its own event mechanism, which you get at through the notify subcommands. It's giving main character energy, honestly. 👑

The exact behaviour of the command depends on the option argument that follows the notify argument. These are the supported forms:

pathName notify bind ?object? ?pattern? ?+??script?

This one associates Tcl scripts with events generated by a treectrl widget. Give it all three arguments and notify bind will arrange for script (a Tcl script, bestie) to be evaluated whenever the event(s) specified by pattern get generated by this treectrl widget. If script is prefixed with a "+", it gets appended to whatever binding already exists for pattern; otherwise script replaces any existing binding. And if script is an empty string, the current binding for pattern is destroyed, leaving pattern unbound. In every case where you hand over a script argument, notify bind returns an empty string.

If pattern is specified without a script, then you get back the script currently bound to pattern, or an empty string if there's no binding for pattern. And if neither pattern nor script is specified? Then the return value is a list whose elements are all the patterns for which bindings exist for object. 🌸

The object argument determines which window(s) the binding applies to. If object begins with a dot, like .a.b.c, then it must be the path name for a window; otherwise it can be an arbitrary string. Just like the regular bind command, bindings on window names are automatically removed if that window is destroyed. 🦋

pathName notify configure object pattern ?option? ?value? ?option value ...?

Sets and retrieves options for bindings created by the notify bind command.

No option specified? The command returns a list with option-value pairs describing all the available binding options for pattern on object. option specified with no value? Then you get the current value of that option. One or more option-value pairs specified? Then the command modifies the given option(s) to have the given value(s) for the binding, and in that case it returns an empty string. 💖

The following binding options are supported:

  • -active boolean — specifies if the binding should be active. As long as this option is specified as false, a binding script will not be evaluated when the corresponding event is generated. 🚫

pathName notify detailnames eventName

Returns a list containing the names of all details which are installed for the event with the name eventName — whether that's by means of the notify install widget command or by the treectrl widget itself.

pathName notify eventnames

Returns a list containing the names of all events which are installed by means of the notify install widget command or by the treectrl widget itself.

pathName notify generate pattern ?charMap? ?percentsCommand?

This command makes the treectrl widget generate an event. It's typically used to generate dynamic events created by the notify install command, but it can be used to generate static events too, no judgement. The event specified by pattern is generated, and any active binding scripts on the event are evaluated after undergoing %-substitution. If there are details defined for the event, pattern must describe an <eventName-detail> pair — otherwise pattern should just be <eventName>.

The optional charMap is a list of char-value pairs, like the form returned by array get. Each char has to be exactly one character. The charMap is used in %-substitution.

If percentsCommand is specified, then it'll be used to perform %-substitution on any scripts bound to the event. If percentsCommand is not specified and the event is dynamic, then the %-substitution command passed to notify install will be used if it was provided. If the event is static, or no %-substitution command is available, then all %-substitution is done using charMap only. Peep notify install for a description of percentsCommand. ✨

pathName notify install pattern ?percentsCommand?

Installs a new event or detail specified by pattern. Events created by this command are called dynamic, whereas events created by the treectrl widget itself are called static. You can also call this command to set or retrieve the percentsCommand for an existing dynamic event.

The optional percentsCommand is a list containing the name of a Tcl command, plus any optional arguments, to which five additional arguments will be appended. That command gets called to perform %-substitution on any scripts bound to the event specified by pattern (go look at EVENTS AND SCRIPT SUBSTITUTIONS). PercentsCommand should be defined like this:

proc percentsCommand {?arg arg ...? char object event detail charMap} {
                        switch -- $char {
                        ...
                        }
                        return $value
}

The optional arg arguments are part of the percentsCommand list. Char is the %-character to be substituted. Object is the same as the argument to notify bind. Event and detail specify the event. CharMap is the same as the argument to notify generate. PercentsCommand should return the value to replace the %-character by. And if an error occurs evaluating percentsCommand, the %-character is replaced by itself. 😭 (rude, but okay.)

notify install returns the current percentsCommand for the event, or an error if the event is not dynamic.

pathName notify install detail eventName detail ?percentsCommand?

Deprecated. Use notify install with a pattern of <eventName-detail> instead. 👵

pathName notify install event eventName ?percentsCommand?

Deprecated. Use notify install with a pattern of <eventName> instead. 👵

pathName notify linkage pattern

Returns a string telling you whether the specified event or detail is created by means of the notify install widget command (dynamic) or by the treectrl widget itself (static).

pathName notify linkage eventName ?detail?

Deprecated. Use notify linkage with a pattern of <eventName> or <eventName-detail> instead. 👵

pathName notify unbind object ?pattern?

No pattern? Then all bindings on object are removed. pattern specified? Then the current binding for pattern is destroyed, leaving pattern unbound. Byeeee 💅

  • pathName notify uninstall pattern — if the event or detail that pattern points at is static (meaning the treectrl widget made it itself, it's not yours to touch), this straight-up throws an error at you 😭. Otherwise the dynamic event or detail gets yeeted. And if you name an event without a detail? Every single detail under that event goes too. Gone. Periodt.
  • pathName notify uninstall detail eventName detail — deprecated, bestie. Don't do it. Use notify uninstall with a pattern of <eventName-detail> instead. 💅
  • pathName notify uninstall event eventName — also deprecated. Same deal: use notify uninstall with a pattern of <eventName> instead.

  • pathName numcolumns — deprecated. Use the column count command instead, it's the moment.
  • pathName numitems — deprecated too. Use the item count command instead.
  • pathName orphans — hands you back a list of the item ids of every item with no parent. When an item gets created it has no parent by default (lil baby item, no family), and it can become an orphan later via the item remove widget command. Just so you know: the root item is not returned. Not invited to this list. 🫶
  • pathName range first last — deprecated. Use the item range command instead.

🌈 pathName scan option args

This is how scanning gets implemented on treectrls. Two forms, depending on option:

  • pathName scan mark x y — records x, y, and the treectrl's current view. It's built to hang out with the scan dragto commands you run later. Typically you'd wire this up to a mouse button press inside the widget, and x and y are the mouse coords. Returns an empty string. ✨
  • pathName scan dragto x y ?gain? — this one does the math: it takes the difference between its x and y args (usually mouse coords, again) and the x and y args from the last scan mark on this widget. Then it nudges the view by gain times that coordinate difference, where gain defaults to 10. Usually hooked to mouse motion events, so it feels like you're dragging the treectrl at high speed through its window 🏎️. Return value is an empty string.

👀 pathName see itemDesc ?columnDesc? ?option value ...?

Adjusts the view so the item described by itemDesc is visible. If it's already visible, this command literally does nothing — no notes, no drama. Otherwise the treectrl scrolls to bring the item into view, and the matching <Scroll-x> and/or <Scroll-y> events get generated 🔥. If you pass columnDesc, then it's one specific column of the item that gets scrolled into view instead of the whole entire item.

The options it supports:

  • -center flags — flags is a string holding zero or more of the characters x or y. Use it to center the item horizontally and/or vertically in the window. And here's the tea: the item gets centered regardless of whether it's already visible. It's centered now. It said what it said. 💅

🎀 pathName selection option args

This is your whole selection-adjustment situation inside a treectrl. Several forms, depending on option:

  • pathName selection add first ?last? — first and last (if you give it) have to be valid item descriptions. If you specify both first and last, they can only refer to a single item; in that case the command adds every unselected item in the range between first and last, inclusive, to the selection — without touching the selected state of anything outside that range. If you only give first, then every unselected item described by first gets added. A <Selection> event is generated if anything actually got added. 🦋
  • pathName selection anchor ?itemDesc? — give it itemDesc and the selection anchor gets set to that item. The selection anchor is the end of the selection that stays fixed while you drag out a selection with the mouse. You can refer to the anchor item using the item description anchor. Heads up: this command does not modify the selection state of any item — it's just here to hold the spot. Returns the unique id of the selection anchor item. 👑
  • pathName selection clear ?first? ?last? — first and last (if specified) must be valid item descriptions. If you give both, they may refer to a single item only; then any selected items between first and last (inclusive) get removed from the selection, and nothing outside that range is affected. If you only give first, then every selected item described by first gets removed. If you give neither, then all selected items get removed. A <Selection> event is generated if any items were removed. 😭
  • pathName selection count — returns an integer: how many items in the treectrl are currently selected. Simple. Iconic.
  • pathName selection get ?first? ?last? — with no extra args, the result is an unsorted list of the item ids of everything currently selected in the treectrl. If nothing's selected, you get an empty string back. The optional first and last are treated as indices into the sorted list of selected items — they let you do in-place lindex and lrange operations on the selection. For example:
  • pathName selection includes itemDesc — returns 1 if the item described by itemDesc is currently selected, 0 if it isn't. Vibe check on one item, basically. 💖
  • pathName selection modify select deselect — both select and deselect are a possibly-empty list of item descriptions. Any unselected items in select get added to the selection, and any selected items in deselect get removed (except for the ones that are also sitting in select — they survive 💪). A <Selection> event is generated if any items were selected or deselected.

⭐ pathName state option args

This command manipulates the list of user-defined item states — peep the STATES section below for the full lore. You can also manage item states with the item state command, and for header-rows you'd use the header state widget command instead. The exact behavior depends on the option argument that comes right after state. Supported forms:

  • pathName state define stateName — defines a brand new state named stateName, which must not be the name of a state that already exists. No dupes allowed, bestie. 🙈
  • pathName state linkage stateName — returns a string telling you whether the state is user-defined via the state define widget command (dynamic) or predefined by the treectrl widget itself (static). Basically: is it yours or is it the widget's? 🧚
  • pathName state names — returns a list of the names of all user-defined states. The whole roster. ✨
  • pathName state undefine ?stateName ...? — every stateName has to be the name of a user-defined state. This removes that state from the list of user-defined states. Bye girl 👋

💜 pathName style option ?element? ?arg arg ...?

This one manipulates styles, and honestly you can think of a style as a geometry manager for elements. The exact behavior depends on the option argument that follows style. Supported forms:

  • pathName style cget style option — returns the current value of the option named option associated with the style given by style. option can be any of the values accepted by the style configure widget command.

This command also accepts the -statedomain option. 💅

  • pathName style configure style ?option? ?value? ?option value ...? — just like the configure widget command, except it modifies options tied to the style given by style instead of options for the whole entire treectrl widget. If you give no option, the command returns a list describing all the available options for style (check Tk_ConfigureInfo for the format of that list). If you give option with no value, you get back a list describing just that one named option — and that list will be identical to the corresponding sublist from the no-option version. If you hand it one or more option-value pairs, then it modifies those option(s) to the given value(s) in style, and returns an empty string.

The options it supports:

  • -buttony offset — the distance from the top of the item where the expand/collapse button should be drawn. If offset is an empty string (which is the default), the button gets centered vertically in the item. The value can take any of the forms that Tk_GetPixels accepts. Heads up: this option only does anything when the style is set in an item in the tree column. 🌸
  • -orient varName — which orientation to use when laying out the elements attached to this style. Must be either horizontal (the default) or vertical, or an abbreviation of one of those two. Pick a lane bestie 🎀

pathName style create name ?option value ...? 🎀

Creates a brand new style, and it gets the unique user-defined name name. Bestie, after name you can drop any number of option-value pairs, and each one sets one of the configuration options for that style. Wanna know what options exist? Go look at the style configure command, it's all there. ✨

The result of this command is the name of the new style (which is literally the same as the name option). It's giving "I made this and it's mine". 💅

This command also accepts the -statedomain option, with a value of either header or item, to specify where this style will be displayed. 🦋


pathName style delete ?style ...? 💀

Deletes each of the named styles and returns an empty string. Simple. Slay.

But ok heads up 🫶 — if a style is deleted while it's still being used to display one or more items, it also gets removed from the style list of those items. So it's not just poof-gone-and-nothing-else-happens, the items notice.


pathName style elements style ?elementList? 🌸

Specifies which elements should be layed out by this style. Every element of elementList has to be the name of an element created by the widget command element create. Duplicate names in elementList? Ignored, we don't do repeats here. 🙈

An element that was specified in a former call of this command for style, but is not included in elementList, will be deleted from the elements layed out by style. So yeah, this call fully overwrites the vibe.

Every element used by a style must have been created with the same value for the -statedomain option. No mixing, bestie, that's a hard rule. ⭐

If the elementList argument is not specified, a list is returned containing the currently defined elements of style. Peek-a-boo, there they are. 👑


pathName style layout style element ?option? ?value? ?option value ...? 🧚

This one is basically the configure widget command's twin, except it modifies options used by style for laying out element, instead of modifying options for the whole entire treectrl widget. Iconic sibling energy. 💖

So, the deets:

  • No option specified → the command returns a list with option-value pairs describing all the available options for the layout. 🌈
  • option specified with no value → the command returns the value of that named option.
  • One or more option-value pairs specified → the command modifies the given option(s) to have the given value(s) for the layout, and in this case it returns an empty string.

The options of a layout have effect on exactly the one element element managed by style. Lowkey laser-focused. Here's what's supported:

  • -detach boolean — Specifies whether the element should be positioned by itself, i.e. independent from the other elements. The default is false.
  • -center flags — Flags is a string that contains zero or more of the characters x or y. x causes the element to be centered horizontally, y causes the element to be centered vertically. When more than one element has -center layout, all the elements between the first and last with -center layout in the style's list of elements are centered as a group. Consider the following when there is another element to the right of MyElement:
    • With the first call, MyElement will be centered only within the space that is not occupied by the other element, so MyElement will appear off-center towards the left of the style.
    • With the second call, MyElement will be centered within the style so long as it doesn't overlap the other element.
  • -draw boolean — This is a per-state option that determines whether an element should be drawn. If the value of the option evaluates to false for a given item state, then the element is not drawn, although it still consumes space in the layout. Ghost element, still taking up room. 👻
  • -expand flags — This option allows the external padding around the element to increase when a style has more screen space than it needs. Flags is a string that contains zero or more of the characters n, s, w or e. Each letter refers to the padding on the top, bottom, left, or right that should be allowed to increase. This option is typically used to justify an element. The default is an empty string.
  • -iexpand flags — This option allows the internal padding of the element and the display area of the element to increase when a style has more screen space than it needs. Flags is a string that contains zero or more of the characters x, y, n, s, w or e. For n, s, w and e, each letter refers to the padding on the top, bottom, left, or right that should be allowed to increase. For x and y, each letter refers to the horizontal and vertical screen space the element can display itself in (i.e., the space between the padding). Note that if the -union option is specified for this element, then the x and y flags have no effect, since the size of an element with -union layout is determined by the elements it surrounds. The default is an empty string.
  • -indent boolean — For item styles, this option specifies whether the element should be positioned to the right of the button/line area in the tree column. When false, the element is displayed beneath the buttons and lines in the tree column. This option is ignored unless the -detach option is true.

For header styles, this option specifies whether the element should be positioned to the right of the -canvaspadx padding. This option is ignored unless the -detach option is true or the -union option is specified.

The default is true.

  • -ipadx amount
  • -ipady amount — Amount specifies how much internal padding to leave on the left and right (for -ipadx) or top and bottom (for -ipady) sides of the element. Amount may be a list of two values to specify padding for the two sides separately. The default value is 0. This option is typically used with the -union layout option, to create space around the enclosed elements. 🎁
  • -minheight pixels
  • -height pixels
  • -maxheight pixels — Specifies the minimum, fixed, and maximum height of the display area of the element. The default is unspecified.
  • -minwidth pixels
  • -width pixels
  • -maxwidth pixels — Specifies the minimum, fixed, and maximum width of the display area of the element. The default is unspecified.
  • -padx amount
  • -pady amount — Amount specifies how much external padding to leave on the left and right (for -padx) or top and bottom (for -pady) sides of the element. Amount may be a list of two values to specify padding for the two sides separately. The default value is 0.
  • -squeeze flags — This option allows the display area of an element to decrease when a style has less space than it needs. Flags is a string that contains zero or more of the characters x or y. x allows display area to decrease horizontally, y allows display area to decrease vertically. This option is typically used for text elements and will cause the text element to display an ellipsis (...) and/or wrap lines. The default is an empty string.
  • -sticky flags — This option controls how the actual display information (image, text, etc) of an element is positioned (or stretched) within its display area. Flags is a string that contains zero or more of the characters n, s, w or e. Each letter refers to the top, bottom, left or right side of the display area that the display information should "stick" to. The default is nswe.
  • -union elementList — Specifies a list of other elements which this element will surround. The size of an element with -union layout is determined by the size and position of the elements in elementList. The -ipadx and -ipady options in this case refer to the distance of the edges of the display area of this element from those elements it surrounds. This option is typically used to display a selection rectangle around a piece of text. If none of the elements in elementList are visible, then the element is not displayed. 🫶

and yes bestie, we're still going — more of this page is coming, don't you dare close the tab 💜

  • -visible boolean — a per-state option, and it's the one that decides if an element is even showing up to the party. If this option evaluates to false for a given item state, the element is not displayed and it consumes no space in the layout. Like, it fully ghosts the layout, no seat saved, no crumbs. 🫥

pathName style names

Returns a list containing the names of all existing styles. Your whole wardrobe of looks, listed out. 👗✨


pathName theme option ?arg ...?

Okay bestie, this one is for interacting with the platform-specific theme. The exact behavior depends on the option argument that comes right after the theme argument, so like, pay attention to which one you're picking. The supported forms are:

pathName theme platform

Returns the API used to draw themed parts of the treectrl. Here's the tea per platform:

  • On Mac OS X the result is always aqua.
  • On MS Windows the result is visualstyles if the uxtheme.dll was loaded and visual themes are in use, otherwise X11 is returned to indicate the Tk Xlib calls are drawing the themed parts.
  • On Unix systems the result is gtk if the Gtk+ version of treectrl was built, otherwise X11 is returned.

pathName theme setwindowtheme appname

Heads up: this command is available on MS Windows only. Sorry to everyone else, it's giving platform exclusive. 💅

If appname is "Explorer" then the item buttons look like those in the Explorer file browser (disclosure triangles under Windows Vista/7). If appname is an empty string then the buttons revert to their default appearance according to the system's current visual style. So cute, so themed. 🪟


pathName toggle</purge> ?-recurse? ?itemDesc ...?

Use item toggle instead. That's it, that's the whole note. This one's deprecated, go use the other one. 🙈


pathName xview ?args?

This command is used to query and change the horizontal position of the information displayed in the treectrl's window. It can take any of the following forms:

pathName xview

Returns a list containing two elements. Each element is a real fraction between 0 and 1; together they describe the horizontal span that is visible in the window. For example, if the first element is .2 and the second element is .6, then 20% of the tree's area is off-screen to the left, the middle 40% is visible in the window, and 40% of the tree is off-screen to the right. These are the same values passed to scrollbars via the -xscrollcommand option. Math girlies rise 🧮✨

pathName xview moveto fraction

Adjusts the view in the window so that fraction of the total width of the tree is off-screen to the left. Fraction must be a fraction between 0 and 1. A <Scroll-x> event is generated. 🎀

pathName xview scroll number what

This command shifts the view in the window left or right according to number and what.

  • Number must be an integer.
  • What must be either units or pages or an abbreviation of one of these.

If what is units, the view adjusts left or right in units determined by the -xscrollincrement option (which may be zero, see the description of that option). If what is pages then the view adjusts in units of nine-tenths the window's width. If number is negative then information farther to the left becomes visible; if it is positive then information farther to the right becomes visible. A <Scroll-x> event is generated. Scroll slay. 🛼


pathName yview ?args?

This command is used to query and change the vertical position of the information displayed in the treectrl's window. It can take any of the following forms:

pathName yview

Returns a list containing two elements. Each element is a real fraction between 0 and 1; together they describe the vertical span that is visible in the window. For example, if the first element is .6 and the second element is 1.0, the lowest 40% of the tree's area is visible in the window. These are the same values passed to scrollbars via the -yscrollcommand option. 💜

pathName yview moveto fraction

Adjusts the view in the window so that fraction of the tree's area is off-screen to the top. Fraction is a fraction between 0 and 1. A <Scroll-y> event is generated. 🌸

pathName yview scroll number what

This command adjusts the view in the window up or down according to number and what.

  • Number must be an integer.
  • What must be either units or pages.

If what is units, the view adjusts up or down in units of the -yscrollincrement option (which may be zero, see the description of that option). If what is pages then the view adjusts in units of nine-tenths the window's height. If number is negative then higher information becomes visible; if it is positive then lower information becomes visible. A <Scroll-y> event is generated. Up and down, no cap, we love a full scroll moment. 🦋

💖 HEADERS 💖

okay so bestie, listen up: a treectrl widget can show zero or more rows of column headers. and when you create a treectrl widget, you also get a single row of column headers (aka a header-row) created right alongside it — that top header-row is forever, you literally cannot delete it. 🫶

Want more rows? Make them with the header create command, and yeet them with header delete. ✨

There are no commands for changing the order of header-rows; they get displayed top to bottom in the order they were created. that's just the vibe, no reordering the stack. 🎀

Drag-and-drop reordering of column headers is supported within a widget though. to control column header drag-and-drop, use the header dragconfigure command. 🔥

Header-rows in a treectrl may be specified in a number of ways — see HEADER DESCRIPTION below. 👑

The appearance of individual column headers within a header-row can be customized in two different ways:

  1. By configuring various column header options with the header configure command.
  2. By assigning a style to a column header with the header style command.

When one of the options below is specified as per-state, the state names are those described in STATES for headers only, i.e. do not use item state names. 💀

The following options are supported for each individual column header:

  • -arrow direction — says whether or not a sort arrow should be drawn in the column header. direction must be one of none (the default), up, or down. ⬆️⬇️
  • -arrowbitmap bitmap — a per-state option, fr: the name of a bitmap to use to draw the arrow if this column's -arrow option is not none.
  • -arrowgravity direction — which side the sort arrow gets packed onto, if there's more space for drawing the arrow than needed. direction must be either left (the default) or right.
  • -arrowimage image — a per-state option, fr: the name of an image to use to draw the sort arrow if this column's -arrow option is not none. If an image is specified for a certain state, it overrides the -arrowbitmap option.
  • -arrowpadx amount — how much padding to leave on the left and right of the sort arrow. amount may be a list of two values to specify padding for left and right separately; it defaults to 6.
  • -arrowpady amount — how much padding to leave on the top and bottom of the sort arrow. amount may be a list of two values to specify padding for top and bottom separately; it defaults to 0.
  • -arrowside side — on which side of the bitmap/image/text the sort arrow should be drawn. side must be either left or right (the default).
  • -bitmap bitmap — the name of a bitmap to display to the left of the column title. 🖼️
  • -background color — a per-state option, fr: the color to use for the background of the column header.
  • -borderwidth size — a non-negative value indicating the width of the 3-D border to draw around the outside of the column header (if such a border is being drawn; the -relief column option decides that). the value may have any of the forms acceptable to Tk_GetPixels.
  • -button boolean — says whether or not the column header should be treated like a pushbutton. when this option is true, the default bindings track <Button-1> events in the header and generate a <Header-invoke> event when a <ButtonRelease-1> event occurs in the header. see DYNAMIC EVENTS. 🖱️
  • -font fontName — the font to use for displaying the column title inside the column header. when the value of this option is unspecified, the font specified by the widget option -headerfont is used.
  • -image image — the name of an image to display to the left of the column title. this option overrides the -bitmap column option.
  • -imagepadx amount — how much padding to leave on the left and right of the image (or bitmap). amount may be a list of two values to specify padding for left and right separately; it defaults to 6.
  • -imagepady amount — how much padding to leave on the top and bottom of the image (or bitmap). amount may be a list of two values to specify padding for top and bottom separately; it defaults to 0.
  • -justify justification — this option determines how the image and text in the column header are positioned. must be one of left (the default), center, or right.
  • -state state — specifies one of three states for the column header: normal, active, or pressed. the active state is used when the mouse is over the header. the pressed state is used when the mouse button is pressed in the header. 🌸 changing the value of this option also affects the current set of header states for the column header, which may affect both the per-state options mentioned here (such as -arrowimage) as well as the elements in any style that may be assigned to the column header.
  • -text text — a text string to be displayed as the column title. ✍️
  • -textcolor color — a per-state option, fr: the color to display the column title with. when the value of this option is unspecified, the title will be drawn according to the system theme color, if any, otherwise the widget option -headerforeground is used. the default is unspecified.
  • -textlines count — the maximum number of lines of text to display in the column title. if this value is zero, the number of lines displayed is determined by any newline characters and the effects of wrapping when the column width is less than needed. the default is 1.
⚠️ Note: Under OSX/Aqua this value is always set to 1 when the treectrl's -usetheme option is true, because the Appearance Manager uses a fixed height for the column header; there is only room for a single line of text. 😭
  • -textpadx amount — how much padding to leave on the left and right of the text. amount may be a list of two values to specify padding for left and right separately; it defaults to 6.
  • -textpady amount — how much padding to leave on the top and bottom of the text. amount may be a list of two values to specify padding for top and bottom separately; it defaults to 0.

🦋 HEADER DESCRIPTION 🦋

Many of the commands for a treectrl take as an argument a description of which header-rows to operate on. a header description is a properly-formed tcl list of keywords and arguments. the first word of a header description must be one of the following:

  • id — a unique header-row identifier, where id should be the return value of a prior call of the header create widget command, or 0 to specify the ever-present top header-row. 💅
  • QUALIFIERS — a list of qualifiers. this gives the same result as all followed by QUALIFIERS; i.e., every header-row is tested for a match.
  • tagExpr QUALIFIERS — tagExpr is a tag expression (see ITEM AND COLUMN TAGS) against which every header-row's tags are tested for a match. ⚠️ you may run into trouble if tagExpr looks like a header-row id or other keyword; also, tagExpr must look like a single list element since header-row descriptions are properly-formed lists. to be safe you may want to use the tag qualifier followed by tagExpr.
  • all QUALIFIERS — matches every header-row which satisfies QUALIFIERS.
  • first QUALIFIERS — indicates the top header-row of the treectrl, or the first header-row starting from the top that satisfies QUALIFIERS.
  • end QUALIFIERS
  • last QUALIFIERS — indicates the last header-row which satisfies QUALIFIERS.

🌈 QUALIFIERS 🌈

The word QUALIFIERS above represents a series of zero or more of the following terms that changes which header-row is chosen:

  • tag tagExpr — tagExpr is a tag expression (see ITEM AND COLUMN TAGS) against which a header-row's tags are tested for a match.
  • visible — when this qualifier is given, only header-rows that are displayed are matched. a header-row is displayed only if both the -showheader widget option and -visible header-row option are true. also, if only the tail column is visible, then header-rows are not displayed. 👀
  • !visible — when this qualifier is given, only header-rows that are not displayed are matched.

✨ COLUMNS ✨

okay bestie, here's where it gets good. 💅 a treectrl can show a whole bunch of columns hanging out next to each other, and an item is basically a row that stretches across all of them. main character spanning the whole timeline fr fr.

you can set up columns in a bunch of different ways — peep COLUMN DESCRIPTION below for the deets.

there's always one special lil guy: the tail column. 👑 it eats up all the space to the right of the last ordinary column. it has no unique ID — the only way to name it is with the keyword tail. periodt.

for compatibility with older versions of treectrl (back when it couldn't do more than one row of column headers 😭), any of the config options from the HEADERS section — stuff like -arrow, -text, etc — can be passed to the top header-row through the column configure command and queried with the column cget command. cute legacy behaviour, we respect it.

the following options are supported for columns:

  • -expand boolean — says whether any extra horizontal space should be spread out to this column or not. lowkey this option does nothing if the -width option is set. 🙈
  • -gridleftcolor color
  • -gridrightcolor color — these two set the color of the lines drawn down the left and right edges of the column. these so-called "grid lines" get drawn over the elements of each item style in the column, and down into the whitespace region below any items. default for each is an empty string, which means no lines drawn, very minimal of them. ✨
  • -itembackground colorList — a list of zero or more colors used as alternating background colors for items in this column. also check the -backgroundmode widget option for more on this vibe.
  • -itemjustify justification — decides how item styles in this column line up horizontally. must be one of left, center, or right. default is an empty string (for compatibility with older versions, iykyk), and in that case the column option -justify is what aligns the item styles in this column.
  • -itemstyle style — style is the name of a style that should be set in this column for newly-created items.
  • -justify justification — decides how item styles in this column line up horizontally, unless it gets overriden by the -itemjustify option for this column. must be one of left (the default 🫶), center, or right.

for compatibility with older versions of treectrl (which did not allow multiple rows of column headers), changing this option also changes the -justify option of the column header in the top header-row. they're linked besties, sorry.

  • -lock lock — lets a column stick to the left or right edge of the window. 🔒 a locked column scrolls vertically but not horizontally. must be one of none (the default), left, or right.
  • -maxwidth size — the maximum size, in screen units, allowed for this column. if size is an empty string, there's no limit on the max size. this option has no effect if the -width option is set.
  • -minwidth size — the minimum size, in screen units, allowed for this column. if size is an empty string, the minimum size of the column is zero. this option has no effect if the -width option is set.
  • -resize boolean — a boolean saying whether the user is allowed to resize the column by dragging the edge of the column's header. default is true.
  • -squeeze boolean — a boolean saying whether the column should shrink when the content width of the treectrl is less than the total needed width of all visible columns. defaults to false, which means the column won't get smaller than its needed width. the column also won't get smaller than the value of its -minwidth option, if specified. this option has no effect if the -width option is set.
  • -stepwidth size — Deprecated. use the treectrl's -itemwidthmultiple option instead. 💀
  • -tags tagList — tagList is a list of tag names that can be used to identify the column. see also the column tag command.
  • -uniform group — when you give it a non-empty value, this option drops the column into a uniform group with other columns that have the same value for -uniform. the space for columns in a uniform group gets allocated so their sizes are always in strict proportion to their -weight values. this option is based on the grid geometry manager.
  • -visible boolean — says whether the column should be displayed or not. 👀
  • -weight integer — the relative weight for apportioning any extra space among columns. a weight of zero (0) means the column won't deviate from its requested size. a column whose weight is two will grow twice as fast as a column of weight one when extra space gets handed out. this option is based on the grid geometry manager.
  • -width size — a fixed width for the column. if this value is an empty string, then the column width is calculated as the maximum of:
    • a) the width requested by items;
    • b) the width requested by the column's header; and
    • c) the column's -minwidth option.

this calculated width is also affected by the -expand, -squeeze, -uniform and -weight options. in any case, the calculated width won't be greater than the -maxwidth option, if specified.

  • -widthhack boolean — Deprecated. use the treectrl's -itemwidthequal option instead. 🙈

🌈 COLUMN DESCRIPTION 🌈

so many of the commands and options for a treectrl take, as an argument, a description of which column to operate on. check the EXAMPLES section for examples, bestie. the initial part of a column description has to start with one of these terms:

  • id — the unique column identifier, where id should be the return value of a prior call of the column create widget command. see also the -columnprefix option.
  • QUALIFIERS — a list of qualifiers. this gives the same result as all followed by QUALIFIERS; i.e., every column is tested for a match.
  • tagExpr QUALIFIERS — tagExpr is a tag expression (see ITEM AND COLUMN TAGS) against which every column's tags are tested for a match. this keyword cannot be followed by any modifiers unless a single column is matched. you may run into trouble if tagExpr looks like a column id or other keyword; also, tagExpr must look like a single list element since column descriptions are properly-formed lists. to be safe you may wanna use the tag qualifier followed by tagExpr.
  • all QUALIFIERS — every column, including the tail column if the command allows it, which match QUALIFIERS.
  • first QUALIFIERS — the leftmost column of the treectrl which matches QUALIFIERS.
  • end QUALIFIERS
  • last QUALIFIERS — the rightmost column of the treectrl (but not the tail column) which matches QUALIFIERS.
  • list columnDescs — columnDescs is a list (a single argument, i.e. list {a b c} not list a b c) of other column descriptions. this keyword cannot be followed by any modifiers unless a single column is matched.
  • order n QUALIFIERS — the *n*th column in the list of columns as returned by the column order command.
  • range first last QUALIFIERS — first and last specify a range of columns. this keyword cannot be followed by any modifiers unless a single column is specified.
  • tail — the ever-present tail column of the treectrl. 💅
  • tree — the column specified by the -treecolumn option of the treectrl.

the initial part of the column description (matching any of the values above) may be followed by one or more modifiers. a modifier changes the column used relative to the description up to this point. it can be specified in any of these forms:

  • next QUALIFIERS — use the column to the right matching QUALIFIERS.
  • prev QUALIFIERS — use the column to the left matching QUALIFIERS.
  • span N QUALIFIERS — starting with (and counting) the single column specified by the column description so far, walk at most N columns rightwards, stopping if any of the following conditions is met:
    1. A column does not match QUALIFIERS.
    2. A column's -lock option does not match the first column's -lock option.

the word QUALIFIERS above represents a sequence of zero or more of the following terms that changes which column is chosen:

  • tag tagExpr — tagExpr is a tag expression (see ITEM AND COLUMN TAGS) against which a column's tags are tested for a match.
  • !tail — when this qualifier is given, the tail column is not matched. sorry tail, not today. 🙈
  • visible — when this qualifier is given, only columns whose -visible option is TRUE are considered.
  • !visible — when this qualifier is given, only columns whose -visible option is FALSE are considered.

💫 STATES 💫

okay so bestie, every single column header AND every item has a whole lil set of boolean states being tracked. these states are not just decorative — they literally decide how headers and items look, and the tea on that is spilled in detail in PER-STATE OPTIONS. and important: the state set for headers is completely separate from the state set for items. two different friend groups, no crossover. 🙅‍♀️


👑 HEADER STATES 👑

these are the pre-made states every column header gets, no setup needed:

  • active
  • normal
  • pressed — these three mirror whatever a column header's config option -state is set to. and at any given moment, exactly one of them is on in each column header. one at a time, always. periodt.
  • down
  • up — these two mirror the value of a column header's config option -arrow. but if -arrow is none, then neither of these gets set. nothing to see here. 💀
  • background — this one gets set for every header-row whenever the toplevel window holding the treectrl is not the foreground active window. you can't change this one with a widget command, nope — it's handled automatically in reaction to the <Activate> and <Deactivate> windowing system events.
  • focus — this one gets set for every header-row when the treectrl widget has the focus right now. also can't be touched by a widget command; it's maintained in reaction to the <FocusIn> and <FocusOut> windowing system events.

🦋 ITEM STATES 🦋

and these are the pre-made states every item gets:

  • active — at all times, this state is set for exactly one item. the active item is the one keyboard navigation hangs out with. when the treectrl widget gets created, or when the active item gets deleted, the root item becomes the active item. you can change this one with the widget command activate.
  • enabled — set for every item the moment it's created. disabled items cannot be selected and get straight-up ignored by the default bindings when you're navigating with the keyboard. you can change this one with the widget command item enabled.
  • focus — set for every item if the treectrl widget currently has the focus. can't be changed with a widget command; it's maintained in reaction to the <FocusIn> and <FocusOut> events.
  • open — if this state is switched on, the item's descendants are displayed, meaning the item is expanded. if it's switched off, the descendants are not displayed, meaning the item is collapsed. for a brand new item this state is switched on by default. you can change this one with the widget commands item expand, item collapse, or item toggle.
  • selected — set for every item that's part of the selection. you can change this with the widget command selection.

using the widget command state define, you can define up to 27 additional states. yes, twenty-seven. go wild. ✨


🌈 PER-STATE OPTIONS 🌈

so an item's whole visual vibe can change depending on which state it's in — being the active item, being selected, being collapsed, or honestly any combo of those or other states. when a config option is described as per-state, it means the option's value varies depending on the item's state. if a per-state option is given as a single value, that value gets used for all states, easy. otherwise, the per-state option has to be given as an even-numbered list.

for example, to use the font "Times 12 bold" in a text element no matter what state the item is in, you write:

$T element configure MyTextElement -font {{Times 12 bold}}

but if you want a different font when the item is selected, you'd write:

$T element configure MyTextElement -font {{Courier 10} selected {Times 12 bold} {}}

in that example, the -font option reads as "value stateList value stateList". if stateList is an empty list, the value right before it gets used regardless of the item state. a non-empty stateList is a list of states that all have to be set on the item for that preceding value to be used. and plot twist: each stateList can also include state names with a ! sign in front, which means that state must not be set on the item. like:

$T element configure MyRectElement -fill {blue {selected focus} gray {selected !focus}}

so up there, the rect element gets filled blue when the treectrl has the focus AND the item is selected. if the treectrl does not have the focus, the example says gray should be used for selected items. also note: if the item isn't selected, no color is specified for the -fill option at all. nothing. void. 💀

each value-stateList pair gets checked in order, left to right. the value tied to the first stateList that matches the current item state is the one that wins. so bestie, list your stateLists from most-specific to least-specific. don't embarrass yourself:

$T element configure MyRectElement -fill {gray {selected} blue {selected focus}}

written like that, gray will always be used for selected items because it shows up first, and blue will literally never be used for selected items no matter what the focus is doing. order matters, iykyk. 🙈

and a value followed by an empty stateList should always go last, since it'll get chosen regardless of the item's state. it's the safety net. the fallback bestie. 🫶


🎀 ELEMENTS AND STYLES 🎀

elements and styles are the core visual building blocks that decide how items (and optionally column headers) look. an element can be of type bitmap, border, header, image, rect, text or window. one or more elements can be assigned to a style, and the style handles the layout of those elements. honestly the easiest way to think about it: an element is like a Tk widget, and a style is like a Tk geometry manager such as grid, pack or place. iconic pairing tbh. 👑

when an element is created by the element create command, that element is called a master element. same energy for a style created by style create — that's a master style. when a master style gets assigned to a column of an item by the item style set command, a new instance style is allocated, and it refers back to the master style and its master elements. so one master style can be shared by multiple columns of multiple items. and if a master element or master style gets modified, those changes affect all the items whose instance styles and elements refer to those masters. group chat update, everyone sees it. 📣

now, you probably do want the font and selection-rectangle colors shared by all items, but you most likely do not want the text to be identical for every column of every item. so the item element configure command exists to override a master element's config options for one specific column of one item. when you call item element configure (or item text or item image), a new instance element gets allocated if there wasn't one already, and that instance element's options override the master element's.

all the element config options described below are unspecified by default, which means no value whatsoever has been given to the option. and yeah, a boolean option being "unspecified" instead of just "true" or "false" probably sounds weird. the reason: when an instance element used by an item has no value for an option, that instance element looks to the master element for that option's value. this is what lets items showing a certain element get redisplayed when the master element's options change. and the payoff is you don't have to configure the font or text color for every single item in a treectrl one by one — saves CPU cycles AND memory. slay. 💅

you might be thinking "to change the color of a selection rectangle i'd call item element configure when an item gets selected" — but nope, that's usually not the move. allocating a fresh instance element for a selection rectangle just because an item became selected would be wasteful. the actual solution is letting the selection rectangle master element's appearance change based on the item's selected state. and guess what, that's exactly what PER-STATE OPTIONS is for. ✨

for each element type there's a section below describing the options that can modify an element of that type. keep scrolling bestie.


🖼️ BITMAP ELEMENT 🖼️

an element of type bitmap is for displaying a bitmap in an item. here's what it supports:

  • -background color — a per-state option, the color to use for each of the bitmap's '0' valued pixels. if the value for a certain state is an empty string (which is the default), the bitmap is drawn transparent.
  • -bitmap bitmap — a per-state option, the bitmap to display in the element.
  • -draw boolean — deprecated; use the style layout option -draw instead. a per-state option saying whether to draw the element. if the value for a certain state is an empty string (the default), it's treated as true and the element will be drawn.
  • -foreground color — a per-state option, the color to use for each of the bitmap's '1' valued pixels. if the value for a certain state is an empty string (the default), the bitmap's foreground color is black.

🎀 BORDER ELEMENT 🎀

An element of type border is literally here to show a 3D border inside an item. That's it, that's the job. Bestie, here's everything it supports:

  • -background color — per-state option, sets the color for the border's background. And the tea is: if the value for some state is an empty string (which is the default btw), the element just… won't be drawn at all. Gone. Not invited. 💀
  • -draw boolean — deprecated bestie, use the style layout option -draw instead. It's a per-state thing for whether to draw the element. If the value for a state is an empty string (the default), it gets treated as true and the element gets drawn.
  • -filled boolean — says whether the interior of the border should be filled with the background color. If you leave this unspecified (the default), it's treated as false, meaning only the edges get drawn. Just the outline, main character energy but minimal. ✨
  • -height size — the height of the border. If unspecified (the default), the border is exactly as tall as its display area, as decided by the style layout options.
  • -relief relief — per-state option for the border's relief. If the value for a state is an empty string (the default), it's treated as flat. Wanna know the acceptable values? Go read the -relief option in the options manual page, iykyk. 📖
  • -thickness thickness — how thick the edges of the border are.
  • -width size — the width of the border. If unspecified (the default), the border is exactly as wide as its display area, as determined by the style layout options.

👑 HEADER ELEMENT 👑

An element of type header shows a themed (or non-themed) column header background plus a sort arrow. Pro tip fr fr: header elements are best used surrounding other elements via the style layout option -union, so the sort arrow can be displayed correctly. That's the way. 💅

Now, some of these options get their default values from the header state flags set in the column header where the element lives. Specifically:

  • the -arrow option gets its default by checking the up and down state flags
  • the -state option gets its default by checking the active, normal, and pressed state flags

But heads up: if elements of this type get displayed in an item instead of a column header, this whole behavior is not used, because those state flags aren't meaningful for items. Not applicable, no cap. 🙈

Here's everything header elements support:

  • -arrow direction — whether a sort arrow should be drawn. direction has to be one of none, up, or down. If unspecified, it defaults to none (but pls see that note above about header states, okay?).
  • -arrowbitmap bitmap — per-state option naming a bitmap to draw the sort arrow with, as long as this element's -arrow option isn't none. This option is ignored when drawing themed headers on Mac OS X. 🍎
  • -arrowgravity direction — which side the sort arrow gets packed onto, if there's more room than the arrow needs. direction must be left or right. If unspecified, defaults to left. Also ignored when drawing themed headers on Mac OS X.
  • -arrowimage image — per-state option naming an image to draw the sort arrow with, if -arrow isn't none. If an image is specified for a state, it overrides the -arrowbitmap option. Ignored for themed headers on Mac OS X.
  • -arrowpadx amount — how much padding to leave on the left and right of the sort arrow. amount can be a list of two values to set left and right padding separately. If unspecified, defaults to 6. Padding to the right of the arrow is ignored when drawing themed headers on Mac OS X.
  • -arrowpady amount — how much padding to leave on the top and bottom of the sort arrow. amount can be a list of two values for top and bottom separately. If unspecified, defaults to 0. Ignored when drawing themed headers on Mac OS X.
  • -arrowside side — which side of the element the sort arrow gets drawn on. side must be left or right. If unspecified, defaults to right.
  • -background color — per-state option, the color for the non-themed background and 3D border. If unspecified, it defaults to either the Tk button widget's -background or -activebackground color.
  • -borderwidth size — a non-negative value for the width of the non-themed 3D border drawn around the inner edges of the element (if such a border is being drawn, which the -relief option decides). The value can be any of the forms acceptable to Tk_GetPixels. If unspecified, defaults to 2.
  • -state state — one of three states for the element: normal, active, or pressed. The active state is used when the mouse is over the header, and pressed is used when the mouse button is pressed in the header. If unspecified, defaults to normal (but see that note above about header states! 🫶).

🦋 IMAGE ELEMENT 🦋

An element of type image shows an image in an item. Iconic behavior honestly. Here's what it supports:

  • -draw boolean — deprecated, use the style layout option -draw instead. Per-state whether to draw the element. If the value for a state is an empty string (the default), it's treated as true and the element gets drawn.
  • -height size — the requested height of the display area for this element. If unspecified (the default), the element requests a height equal to the height of the image, or zero if there's no image.
  • -image image — per-state option for the image to display in the element.
  • -tiled boolean — a boolean for whether the image should be tiled horizontally and vertically within the element's display area. The default is false.
  • -width size — the requested width of the display area for this element. If unspecified (the default), the element requests a width equal to the width of the image, or zero if there's no image.

💜 RECTANGLE ELEMENT 💜

An element of type rect draws a rectangle in an item. Simple, cute, does the job. The following options are supported:

  • -draw boolean — deprecated, use the style layout option -draw instead. Per-state whether to draw the element. If the value for a state is an empty string (the default), it's treated as true and the element gets drawn.
  • -fill color — per-state option for the color that fills the rectangle's area. If the color for a state is an empty string (the default), then the rectangle won't be filled (but the outline may still be drawn, so it's not fully ghosting you).
  • -height size — the height of the rectangle. If unspecified (the default), the rectangle is exactly as tall as its display area, as determined by the style layout options.
  • -open open — per-state option for which edges of the rectangle get left open. You use this to get an incomplete drawing of the outline and rounded corners, often to make the rectangle look like it's extending over adjacent columns or items. open is a string with zero or more of the characters n, s, e, or w. Each letter means an edge (north, south, east, or west) where the outline and rounded corners won't be drawn. The default is the empty string, which draws all the rounded corners and the outline.
  • -outline color — per-state option for the color of the rectangle's outline. If the color for a state is an empty string (the default), then no outline is drawn for the rectangle.
  • -outlinewidth outlineWidth — the width of the outline drawn around the rectangle's region. outlineWidth can be in any of the forms acceptable to Tk_GetPixels. If this option is specified as an empty string (the default), then no outline is drawn.
  • -rx radius
  • -ry radius — these two set the x and y radius of each corner of a rounded rectangle, in any of the forms acceptable to Tk_GetPixels.
  • -showfocus boolean — a boolean for whether a "focus ring" should be drawn around the rectangle, if the item containing the rectangle is the active item and the treectrl widget currently has the focus. If this option is specified as an empty string (the default), then a focus rectangle is not drawn.
  • -width size — the width of the rectangle. If unspecified (the default), the rectangle is exactly as wide as its display area, as determined by the style layout options.

🌸 TEXT ELEMENT 🌸

okay bestie, an element of type text is literally just there to display text inside an item 💅 and here's every single option it supports:

  • -draw boolean — deprecated 🚨 like, use the style layout option -draw instead, ok? This is a per-state option for whether to draw the element. If the value for a certain state is an empty string (that's the default), it's treated as true and the element will be drawn.
  • -data data — a value that, together with the -datatype and -format options, gets displayed as text ✨
  • -datatype dataType — the type of info living in the -data option. Acceptable values are double, integer, long, string, or time. no cap.
  • -fill color — per-state option for the foreground color used when displaying text 🎨

In items, if the color for a certain state is an empty string (the default), then the text is displayed using the color specified by the treectrl's -foreground option.

In headers, if the color for a certain state is an empty string, then the text is displayed using the system theme color on Gtk+; if that color isn't specified then the -headerforeground option is used.

  • -font font — per-state option for the font used when displaying the text 🎀 If the font for a certain state is an empty string, the text is displayed using the font specified by the treectrl's -font option in items, or the -headerfont option in headers.
  • -format formatString — this one specifies the format string used to display the value of the -data option. If -datatype is time, formatString should be a valid format string for the Tcl clock command. For all other -datatype values, formatString should be a valid format string for the Tcl format command. If you don't specify this value, these defaults kick in: for -datatype double it's "%g", for -datatype integer it's "%d", for -datatype long it's "%ld", for -datatype string it's "%s", and for -datatype time it's the default format string of the Tcl clock command.
  • -justify how — how to justify the text when multiple lines are displayed. how must be one of left, right, or center. If this option is an empty string (the default), left is used. ✨
  • -lines lineCount — the max number of lines to display. If more than lineCount lines would be shown, the last line gets truncated with an ellipsis on the right 💀 If this option is zero or an empty string (the default), there is no limit to the number of lines displayed.
  • -lmargin1 pixels — pixels is a screen distance specifying how much a line of text should be indented. If a line of text wraps, this option only applies to the first line on the display; the -lmargin2 option controls the indentation for the lines after that. If this option is zero or an empty string (the default), then the line isn't indented. This option was based on the Tk Text widget tag option of the same name.
  • -lmargin2 pixels — pixels is a screen distance specifying how much a line of text should be indented. If a line of text wraps, this option only applies to the second and later display lines for a line of text. If this option is zero or an empty string (the default), then the line isn't indented. Also based on the Tk Text widget tag option of the same name 🫶
  • -text string — string specifies a string to be displayed by the element. string may contain newline characters, in which case multiple lines of text get displayed 📝 If this option is specified, the -data, -datatype, -format, and -textvariable options are ignored.
  • -textvariable varName — the name of a variable. The value of that variable is a string to be displayed by the element; if the variable value changes, then the element automatically updates itself to display the new value 😌 iconic. If this option is specified, the -data, -datatype, and -format options are ignored.
  • -underline charIndex — the integer index of a character to underline. 0 corresponds to the first character. If charIndex is unspecified (the default), less than zero, or greater than the index of the last displayed character, the underline isn't drawn.
  • -width size — the maximum line length, in any of the forms acceptable to Tk_GetPixels. For text to wrap lines, the value of the -width option must be less than the needed width of the text, or the display area for this element must be less than the needed width of the text. For the display area to be less than the needed width of the text, one of the style layout options -maxwidth, -width, or -squeeze must be used.
  • -wrap mode — mode specifies how to handle lines in the text that are longer than the maximum line length. Acceptable values are none, char, or word. If this option is unspecified (the default), word is used. Peep the -width option for how the maximum line length is determined 👀

🦋 WINDOW ELEMENT 🦋

an element of type window lets you display a Tk window inside an item. here's everything it supports:

  • -clip boolean — whether the associated Tk window is a borderless frame which should be used to clip its child window so it doesn't overlap the header, borders, or other items or columns. When this option is true, the treectrl manages the geometry of both the -window widget and its first child widget; in this case the -window widget (which should be a borderless frame) is kept sized and positioned so that it is never out-of-bounds 🫶
  • -destroy boolean — whether the associated Tk window should be destroyed when the element is deleted. The element gets deleted when the item containing the element is deleted, when the column containing the element is deleted, or when the style assigned to the item's column is changed. If this option is unspecified (the default), it's treated as false and the Tk window will not be destroyed.
  • -draw boolean — deprecated 🚨 use the style layout option -draw instead. Specifies as a per-state option whether to draw the element. If the value for a certain state is an empty string (the default), it's treated as true and the element will be drawn.
  • -window pathName — the window to associate with this element. The window specified by pathName must either be a child of the treectrl widget or a child of some ancestor of the treectrl widget. pathName may not refer to a top-level window. This option cannot be specified by the element create or element configure commands, only by the item element configure command; i.e., the element must be associated with a particular item. iykyk 💅

💖 ITEM DESCRIPTION 💖

okay bestie, so like, so many treectrl commands need you to tell them which items you're talking about. That's what an item description is: a properly-formed Tcl list of keywords and arguments. periodt. 💅 The first word has to be one of these, no cap:

  • id — the unique item identifier, where id should be the return value of a prior call of the item create widget command, or 0 to specify the ever-present root item. See also the -itemprefix option. 👑
  • QUALIFIERS — specifies a list of qualifiers. This gives the same result as all followed by QUALIFIERS; i.e., every item is tested for a match. ✨
  • tagExpr QUALIFIERS — TagExpr is a tag expression (see ITEM AND COLUMN TAGS) against which every item's tags are tested for a match. This keyword cannot be followed by any modifiers unless a single item is matched. You may run into trouble if tagExpr looks like an item id or other keyword; also, tagExpr must look like a single list element since item descriptions are properly-formed lists. To be safe you may want to use the tag qualifier followed by tagExpr. 🫶
  • active — indicates the item that is currently active, i.e. normally the item specified as argument of the last successful activate widget command, or the root item if no such call happened yet.
  • anchor — indicates the anchor item of the selection, i.e. normally the item specified as argument of the last successful selection anchor widget command, or the root item if no such call happened yet.
  • all QUALIFIERS — indicates every item including orphans which match QUALIFIERS. This keyword cannot be followed by any modifiers unless a single item is matched. 💀
  • first QUALIFIERS — indicates the first item of the treectrl (the root item), or the first item matching QUALIFIERS.
  • end QUALIFIERS — (the original just lists it, bestie, no extra description here)
  • last QUALIFIERS — indicates the last item which matches QUALIFIERS.
  • list itemDescs — ItemDescs is a list (a single argument, i.e. list {a b c} not list a b c) of other item descriptions. This keyword cannot be followed by any modifiers unless a single item is matched.
  • nearest x y — indicates the item nearest to the point given by x and y.
  • rnc row column — indicates the item in the given row and column. The row and column corresponds to the on-screen arrangement of items as determined by the -orient and -wrap options. You can memorize rnc as an abbreviation of "row 'n' column". 🎀
  • range first last QUALIFIERS — first and last specify a range of items. This keyword cannot be followed by any modifiers unless a single item is matched.
  • root — indicates the root item of the treectrl. 👑

The initial part of the item description (matching any of the values above) may be followed by one or more modifiers. A modifier changes the item used relative to the description up to this point. It may be specified in any of the following forms:

  • above — use the item one row above in this column.
  • ancestors QUALIFIERS — use the ancestors of the item (like item ancestors but QUALIFIERS may change which ancestors match). This keyword cannot be followed by any modifiers.
  • below — use the item one row below in this column.
  • bottom — use the item in the last row of this column.
  • child n QUALIFIERS — use the nth child of the item.
  • children QUALIFIERS — use the children of the item (like item children but QUALIFIERS may change which children match). This keyword cannot be followed by any modifiers.
  • descendants QUALIFIERS — use the descendants of the item (like item descendants but QUALIFIERS may change which descendants match). This keyword cannot be followed by any modifiers.
  • firstchild QUALIFIERS — use the first child of the item.
  • lastchild QUALIFIERS — use the last child of the item.
  • left — use the item one column to the left in the same row.
  • leftmost — use the item of the first column in the same row.
  • next QUALIFIERS — use the next item, which is the first item from the following list: the first child, the next sibling or the next sibling of the nearest ancestor which has one.
  • nextsibling QUALIFIERS — use the next sibling of the item.
  • parent — use the parent of the item.
  • prev QUALIFIERS — use the last child of the previous sibling, or the parent if there is no previous sibling.
  • prevsibling QUALIFIERS — use the previous sibling of the item.
  • right — use the item one column to the right in the same row.
  • rightmost — use the item of the last column in the same row.
  • sibling n QUALIFIERS — use the nth child of the item's parent.
  • top — use the item in the first row of this column.

The word QUALIFIERS above represents a series of zero or more of the following terms that changes which item is chosen:

  • depth depth — matches items whose depth (as returned by the depth command) is equal to depth.
  • state stateList — StateList is a list of item state names (static and dynamic, see STATES). Only items that have the given states set (or unset if the '!' prefix is used) are considered.
  • tag tagExpr — TagExpr is a tag expression (see ITEM AND COLUMN TAGS) against which an item's tags are tested for a match.
  • visible — when this qualifier is given, only items that are displayed are considered.
  • !visible — when this qualifier is given, only items that are not displayed are considered.

To get the first item in the list that is enabled:

$T item id "first state enabled"

To get the ancestors that are not open of the last item in the list:

$T item id "last ancestors state !open"

To get the visible descendants of the root item:

$T item id "root descendants visible"

To get every hidden item with tag "a" or "b":

$T item id "all !visible tag a||b"
$T item id "!visible tag a||b"
$T item id "tag a||b !visible"
$T item id "a||b !visible"

✨ EVENTS AND SCRIPT SUBSTITUTIONS ✨

The script argument to notify bind is a Tcl script, which will be evaluated whenever the given event is generated. Script will be executed in the same interpreter that the notify bind command was executed in, and it will run at global level (only global variables will be accessible). If script contains any % characters, then the script will not be evaluated directly. Instead, a new script will be generated by replacing each %, and the character following it, with information from the current event. Unlike the regular Tk bind mechanism, each event generated by a treectrl widget has its own set of %-substitutions. 💅

The following %-substitutions are valid for all static events:

  • %% — replaced with a single %
  • %d — the detail name
  • %e — the event name
  • %P — the pattern, either <event> or <event-detail>
  • %W — the object argument to the notify bind command
  • %T — the treectrl widget which generated the event
  • %? — a list of the format {char value char value ...} for each %-substitution character and the value it is replaced by

The following events may be generated by a treectrl widget:

  • <ActiveItem> — generated whenever the active item changes. 💖
    • %c — the current active item
    • %p — the previous active item
  • <Collapse-before> — generated before an item is collapsed.
    • %I — the item id
  • <Collapse-after> — generated after an item is collapsed.
    • %I — the item id
  • <Expand-before> — generated before an item is expanded. This event is useful if you want to add child items to the item just before the item is expanded. ✨
    • %I — the item id
  • <Expand-after> — generated after an item is expanded.
    • %I — the item id
  • <ItemDelete> — generated when items are about to be deleted by the item delete command.
    • %i — list of items ids being deleted.
  • <ItemVisibility> — generated when items become visible on screen and when items are no longer visible on screen. This event is useful if you have a very large number of items and want to assign styles only when items are actually going to be displayed. 👀
    • %h — list of items ids which are no longer visible.
    • %v — list of items ids which are now visible.
  • <Scroll-x> — generated whenever the view in the treectrl changes in such a way that a horizontal scrollbar should be redisplayed.
    • %l — same as the first fraction appended to -xscrollcommand. Think lower.
    • %u — same as the second fraction appended to -xscrollcommand. Think upper.
  • <Scroll-y> — generated whenever the view in the treectrl changes in such a way that a vertical scrollbar should be redisplayed.
    • %l — same as the first fraction appended to -yscrollcommand. Think lower.
    • %u — same as the second fraction appended to -yscrollcommand. Think upper.
  • <Selection> — generated whenever the selection changes. This event gives information about how the selection changed.
    • %c — same as the selection count widget command
    • %D — list of newly-deselected item ids
    • %S — list of newly-selected item ids

🌈 DYNAMIC EVENTS 🌈

ok so bestie, you already know about the pre-defined static events like <ActiveItem> and <Selection> — cute, iconic, love them. but you can also cook up brand new dynamic events yourself using the notify install command. no cap.

The library scripts serve as a lil example of using a dynamic event called <Header-invoke>, which gets generated when the mouse button is clicked and released over a column header.

# Example application code
treectrl .t
                        puts "column header %C clicked in header-row %H in treectrl %T"
}
# Library code in treectrl.tcl
proc ::TreeCtrl::Release1 {w x y} {
                        ...
                        $w notify generate <Header-invoke> [list H $Priv(header) C $Priv(column)] \
                        [list ::TreeCtrl::PercentsCmd $w]
                        ...
}

So in the example above, a new treectrl widget gets created and the <Header-invoke> event is installed. A script is bound to that event with notify bind, and it prints out the column ID, header ID and widget name to the console. In a real application, any script bound to <Header-invoke> would be used to sort the list based on whichever column header got clicked. slay.

heads up 🫶 there is no percentsCommand argument to notify install; instead, the call to notify generate specifies the %-substitution command.

The charMap argument to notify generate provides a list of %-substitution characters and values, which is what ::TreeCtrl::PercentsCmd uses. In the example, any %C in any script bound to the <Header-invoke> event would be replaced by the value of $Priv(column), and %H would be replaced by $Priv(header). The library procedure ::TreeCtrl::PercentsCmd also supports the same common %-substitution characters as the built-in static events, such as %T, %P, %? etc. 💅

The following dynamic events may be generated by the library scripts:

<ColumnDrag-begin>

This event is generated just after the user begins dragging a column header. At the time this event is generated, the header dragconfigure option -imagecolumn is set to the unique ID of the column being dragged, the -imageoffset option is set to the horizontal distance the mouse pointer has moved, and the -imagespan option is set to the span of the column header that was initially clicked.

<ColumnDrag-indicator>

This event is generated each time a new place to drop the dragged column header is found. At the time this event is generated, the header dragconfigure option -indicatorcolumn is set to the unique ID of the column before or after which the dragged column will be dropped, and the -indicatorspan option is set to the span of the column header for this newly-chosen indicator column.

<ColumnDrag-receive>

This event is generated when the user has successfully dragged and dropped a column header to a new position. The library scripts do not actually move the dragged column. You must bind a script to this event to move the column. See EXAMPLES.

<ColumnDrag-end>

This event is generated after the user finally releases the left mouse button while dragging a column header. This event is generated after all the other <ColumnDrag> events, even when the column wasn't dragged to a new location (i.e., even when no <ColumnDrag-receive> event was generated).

  • %H — The header-row that contains the column header.
  • %C — The column whose header is dragged within the header-row.
  • %b — The column to move the dragged column(s) before. Valid for <ColumnDrag-receive> only.

<Drag-begin>, <Drag-receive>, <Drag-end>

Generated whenever the user drag-and-drops a file into a directory. This event is generated by the filelist-bindings.tcl library code, which is not used by default. See the "Explorer" demos. 🍓

  • %I — The item that the user dropped the dragged items on.
  • %l — (lowercase L) The list of dragged items.

<Edit-begin>, <Edit-accept>, <Edit-end>

The filelist-bindings.tcl code will display a text-editing window if the user clicks on a selected file/folder name. See the "Explorer" demos. ✨

  • %I — The item containing the edited text element.
  • %C — The column containing the edited text element.
  • %E — The name of the edited text element.
  • %t — The edited text.

<Header-invoke>

Generated whenever the user clicks and releases the left mouse button in a column header, if the column header's -button option is true. You can bind a script to this event to sort the list.

  • %H — The header-row that contains the column header.
  • %C — The column whose header was clicked.

<Header-state>

Generated when the column header option -state is changed by the library scripts during Motion and Button events.

  • %H — The header-row that displays the column header.
  • %C — The column within the header-row whose header option -state changed.
  • %s — The new value of the column header option -state.

🎀 DEFAULT BINDINGS 🎀

Tk automatically creates class bindings for treectrl widgets that give them the following default behavior. free of charge, bestie

  1. Clicking mouse button 1 over an item positions the active cursor on the item, sets the input focus to this widget, and resets the selection of the widget to this item, if it is not already in the selection.
  2. Clicking mouse button 1 with the Control key down will reposition the active cursor and add the item to the selection without ever removing any items from the selection.
  3. If the mouse is dragged out of the widget while button 1 is pressed, the treectrl will automatically scroll to make more items visible (if there are more items off-screen on the side where the mouse left the window).
  4. The Left and Right keys move the active cursor one item to the left or right; for an hierarchical tree with vertical orientation nothing will happen, since it has no two items in the same row. The selection is set to include only the active item. If Left or Right is typed with the Shift key down, then the active cursor moves and the selection is extended to include the new item.
  5. The Up and Down keys move the active cursor one item up or down. The selection is set to include only the active item. If Up or Down is typed with the Shift key down, then the active cursor moves and the selection is extended to include the new item.
  6. The Next and Prior keys move the active cursor forward or backwards by one screenful, without affecting the selection.
  7. Control-Next and Control-Prior scroll the view right or left by one page without moving the active cursor or affecting the selection. Control-Left and Control-Right behave the same.
  8. The Home and End keys scroll to the left or right end of the widget without moving the active cursor or affecting the selection.
  9. The Control-Home and Control-End keys scroll to the top or bottom of the widget, they also activate and select the first or last item. If also the Shift key is down, then the active cursor moves and the selection is extended to include the new item.
  10. The Space and Select keys set the selection to the active item.
  11. Control-/ selects the entire contents of the widget.
  12. Control-\ clears any selection in the widget.
  13. The + and - keys expand or collapse the active item, the Return key toggles the active item.
  14. The mousewheel scrolls the view of the widget four lines up or down depending on the direction, the wheel was turned. The active cursor or the selection is not affected.

🦋 GRADIENTS 🦋

Color gradients are an easy way to give your lists a more modern appearance. Since Tk provides no support for drawing gradients, the TkPath extension was used as a guide when implementing gradients in TkTreeCtrl. The current implementation has some limitations, however:

  1. Only linear gradients are supported.
  2. Gradients can only be painted left-to-right or top-to-bottom, not at arbitrary angles.
  3. Gradients look bad on low-color displays. Before using gradients, you should check that the display's color depth is at least 15 or 16 by calling the winfo depth command.
  4. Gradients are fully opaque when XFillRectangle() is used to draw them (see below). This means the opacity value of each color stop is ignored. Keep that in mind if your application is cross-platform.
  5. Rounded rectangles cannot be filled or outlined with a gradient when XFillRectangle() is used to draw gradients (see below). Instead, the rounded rectangle is painted with the gradient's first -stops color.

Gradients may be used in the following places:

  1. The -gridleftcolor and -gridrightcolor options of columns.
  2. The -itembackground option of columns.
  3. The -fill and -outline options of rect elements.
  4. The -fill and -outline options of the marquee configure command.

On Microsoft Windows, GDI+ is used where it is available (gdiplus.dll is dynamically loaded at run-time). On Mac OS X, CoreGraphics is used to draw gradients. With the Gtk+ build of treectrl, libcairo is used to draw gradients. When native gradient support is available, all the talk below about -steps can safely be ignored. periodt.

When no native support for gradients is available, gradients are drawn simply by filling sub-rectangles using XFillRectangle(). The number of sub-rectangles drawn and number of colors that make up the displayed gradient are controlled by the gradient's -steps and -stops options. The number of sub-rectangles is equal to the length of the -stops option multiplied by the value of the -steps option. For example:

$T gradient create myGradient -stops {{0 white} {1 gray}} -steps 8

This gradient will be drawn with 2x8=16 sub-rectangles of color. The higher the -steps value, the smoother the color transitions will be, and the slower the gradient will be to draw. For the best appearance, make the number of sub-rectangles drawn less than or equal to the height or width of the gradient being drawn. So if you have a rect element 18 pixels tall, use a vertical gradient that has steps X stops=18. Avoid using gradients with steps X stops greater than the height or width of the rectangle being drawn, because then colors will overlap. 💀

✨ GRADIENT COORDINATES ✨

okay so bestie, by default a gradient brush is literally exactly the same size as whatever rectangle is being painted. no cap. for example, if a column's -itembackground option specifies a gradient name, then the background of an item is painted with all the colors of the gradient. so a vertical gradient from blue to green will start blue at the top and end with green at the bottom of every item. it's giving consistent, periodt. 💅

but wait — by specifying any of the -bottom, -left, -right or -top gradient options, the size of the gradient brush does not need to match that of the rectangle being painted. these options can be used to make a gradient appear to span across the entire width or height of the treectrl window, or across the entire canvas, for example. main character energy fr fr. 🦋

and lowkey? there is no point specifying -left or -right if the gradient is vertical, since the gradient's colors are constant horizontally, so changing the horizontal size of the brush won't change the appearance of the gradient. same reasoning applies for the -top and -bottom options for a horizontal gradient. so don't do it, bestie, it's a waste of your cute little keystrokes. 💅

package require treectrl
set T [treectrl .t -itemheight 20 -showheader no]
$T gradient create G1 -orient vertical -top {0.0 canvas} -bottom {1.0 canvas} \
                        -stops {{0.0 blue} {0.5 green} {1.0 red}} -steps 25
$T column create -expand yes -itembackground G1
pack $T -expand yes -fill both

✨ EXAMPLES ✨

Get the unique identifier for the leftmost visible column:

set id [$T column index "first visible"]

Delete the leftmost column:

$T column delete "order 0"

Take the visible column that is to the left of the last column, and move that column in front of the tail column:

$T column move "last prev visible" tail

Get the unique identifier for the first visible item:

set id [$T item index "first visible"]

Delete the parent of the item that is under the point x,y:

$T item delete "nearest $x $y parent"

Add the 10th child of the second child of the root item to the selection:

$T selection add "root firstchild nextsibling child 10"

Move a column that the user drag-and-dropped:

$T header dragconfigure -enable yes
$T notify install <ColumnDrag-receive>
$T notify bind MyTag <ColumnDrag-receive> {
                        %T column move %C %b
}

👀 SEE ALSO 👀


🏷️ KEYWORDS 🏷️

  • tree
  • widget

and that's the whole vibe, bestie. this page came from treectrl(n), version 2.4.1. the footer's date slot is empty, so no date — just sparkles. ✨💖

📦 where this page comes from