treectrl(3tk)

โœจ treectrl(3tk) โœจ

okay bestie, welcome to treectrl(3tk) from the Tk Commands manual โ€” it's giving hierarchical multicolumn widget realness. this page is part 1 of 24, and we're starting with the name and the synopsis. no skips, fr fr. ๐Ÿ’–


๐ŸŒธ NAME ๐ŸŒธ

treectrl โ€” create and manipulate hierarchical multicolumn widgets ๐Ÿฆ‹โœจ


โœจ SYNOPSIS โœจ

bestie, here's every single way to call it, exactly as written. don't skip a line, iykyk. ๐Ÿ’…

package require treectrl  2.4.1

treectrl pathName ?options?

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

โœจ DESCRIPTION โœจ

okay so bestie, treectrl pathName ?options? is literally how you birth a new treectrl widget. ๐Ÿ’… The treectrl command creates a new window (the pathName argument) and makes it into a treectrl widget. Extra options (described above) can be specified on the command line or in the option database to configure things like background color and relief. The 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. No cap.

A treectrl is a listbox widget that 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. Periodt.

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 ๐Ÿ’–

  • -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 ๐ŸŽ€

  • -backgroundimage โ€” Command-Line Switch: -backgroundimage ยท 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: -backgroundmode ยท 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 laid 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: -bgimage ยท Database Name: bgImage ยท Database Class: BgImage. Synonym for -backgroundimage. ๐Ÿฆ‹
  • -bgimageanchor โ€” Command-Line Switch: -bgimageanchor ยท 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: -bgimageopaque ยท 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: -bgimagescroll ยท 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: -bgimagetile ยท 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: -buttonbitmap ยท 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: -buttoncolor ยท 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: -buttonimage ยท 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: -buttonsize ยท 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: -buttonthickness ยท 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: -buttonttracking ยท 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: -canvaspadx ยท 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: -canvaspady ยท 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: -columnprefix ยท 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: -columnproxy ยท 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: -columnresizemode ยท 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: -columntagexpr ยท 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: -defaultstyle ยท Database Name: defaultStyle ยท Database Class: DefaultStyle. (no description in this chunk, bestie โ€” keep scrolling for the tea ๐Ÿซ–)
  • โš ๏ธ deprecated alert โ€” bestie, this option is deprecated, so use the column option -itemstyle instead, okay? 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 โ€” no cap, it just can. Each list element should be a valid style name, or an empty string to say "nah, no style for this particular column". And the list of styles gets updated if a style is deleted or if a column is moved. โœจ
  • -doublebuffer โ€” this one literally does nothing anymore, it was just left in for compatibility. Back in the day it used to control the amount of double-buffering used when displaying a treectrl. Now? Nothing. Zero. Void. ๐Ÿ’€
    • Command-Line Switch: -doublebuffer
    • Database Name: doubleBuffer
    • Database Class: DoubleBuffer
  • -headerfont โ€” the font used to draw text in column headers, periodt. The default value is TkHeadingFont where available (so on Tk 8.5+). And heads up, you can override this per-header by setting the -font option for individual column headers. ๐ŸŽ€
    • Command-Line Switch: -headerfont
    • Database Name: headerFont
    • Database Class: Font
  • -headerfg โ€” just a synonym for -headerforeground, that's it, that's the whole thing. ๐Ÿ™ˆ
    • Command-Line Switch: -headerfg
    • Database Name: headerForeground
    • Database Class: Foreground
  • -headerforeground โ€” the color used to draw text in column headers. Default value is the Tk button foreground color (usually black, classic). On Gtk+, the system theme may override this color โ€” rude, I know. This option (and the Gtk+ system theme color) can be overridden by setting the -textcolor option for individual column headers. ๐Ÿ’…
    • Command-Line Switch: -headerforeground
    • Database Name: headerForeground
    • Database Class: Foreground
  • -height โ€” the desired height for the window, in any of the forms acceptable to Tk_GetPixels. Default is 200 pixels. And if this option is less than or equal to zero, the window will not request any size at all โ€” it's giving "I have no opinion, figure it out yourself". ๐Ÿฆ‹
    • Command-Line Switch: -height
    • Database Name: height
    • Database Class: Height
  • -indent โ€” the screen distance an item is indented relative to its parent item, in any of the forms acceptable to Tk_GetPixels. Default is 19 pixels. Nested items need their lil personal space. ๐ŸŒธ
    • Command-Line Switch: -indent
    • Database Name: indent
    • Database Class: Indent
  • -itemgapx โ€” the horizontal spacing between adjacent items, in any of the forms acceptable to Tk_GetPixels. Default is 0. ๐Ÿซถ
    • Command-Line Switch: -itemgapx
    • Database Name: itemGapX
    • Database Class: ItemGapX
  • -itemgapy โ€” the vertical spacing between adjacent items, in any of the forms acceptable to Tk_GetPixels. Default is 0. ๐Ÿซถ
    • Command-Line Switch: -itemgapy
    • Database Name: itemGapY
    • Database Class: ItemGapY
  • -itemheight โ€” a fixed height for every single item, in any of the forms acceptable to Tk_GetPixels. If it's 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. And in any case, items are never shorter than the maximum height of a button if they display one. Default is 0. ๐Ÿ”ฅ
    • Command-Line Switch: -itemheight
    • Database Name: itemHeight
    • Database Class: ItemHeight
  • -itemprefix โ€” 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 gets prefixed with the given string. This can aid debugging, but it is important that your code doesn't assume item ids are integers if you use it. Not me warning you ahead of time instead of letting you find out the hard way. ๐Ÿ˜ญ
    • Command-Line Switch: -itemprefix
    • Database Name: itemPrefix
    • Database Class: ItemPrefix
  • -itemtagexpr โ€” a boolean that enables or disables tag expressions in item descriptions. Go see ITEM AND COLUMN TAGS for the whole lore. ๐Ÿ‘‘
    • Command-Line Switch: -itemtagexpr
    • Database Name: itemTagExpr
    • Database Class: ItemTagExpr
  • -itemwidth โ€” 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 also has no effect (in that case all items are as wide as the column). So like, it's conditional, bestie. ๐Ÿฆ‹
    • Command-Line Switch: -itemwidth
    • Database Name: itemWidth
    • Database Class: ItemWidth
  • -itemwidthequal โ€” a boolean saying whether all items should have the same width. Same vibe check as before: if more than one column is visible, no effect. If -orient is vertical and -wrap is unspecified, no effect (all items are as wide as the column). And if the -itemwidth option is specified, this one has no effect either. ๐ŸŽ€
    • Command-Line Switch: -itemwidthequal
    • Database Name: itemWidthEqual
    • Database Class: ItemWidthEqual
  • -itemwidthmultiple โ€” a screen distance that every item's width will be evenly divisible by, in any of the forms acceptable to Tk_GetPixels. And yes, the same three caveats: more than one column visible โ†’ no effect. -orient vertical with -wrap unspecified โ†’ no effect (all items as wide as the column). -itemwidth specified โ†’ no effect. she's consistent, I'll give her that. โœจ
    • Command-Line Switch: -itemwidthmultiple
    • Database Name: itemWidthMultiple
    • Database Class: ItemWidthMultiple
  • -linecolor โ€” the color used for drawing the connecting lines between related items. Tree family tree vibes. ๐ŸŒˆ
    • Command-Line Switch: -linecolor
    • Database Name: lineColor
    • Database Class: LineColor
  • -linestyle โ€” the appearance of the connecting lines between related items. The value should be dot, which is the default, or solid. That's the whole menu, don't get creative. ๐Ÿ’…
    • Command-Line Switch: -linestyle
    • Database Name: lineStyle
    • Database Class: LineStyle
  • -linethickness โ€” the thickness of the connecting lines between related items, in any of the forms acceptable to Tk_GetPixels. ๐ŸŒธ
    • Command-Line Switch: -linethickness
    • Database Name: lineThickness
    • Database Class: LineThickness
  • -minitemheight โ€” a minimum height for every item, in any of the forms acceptable to Tk_GetPixels. The default is 0, which means 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 the -height item option is specified. And in any case, items are never shorter than the maximum height of an expand/collapse button. ๐Ÿ“
    • Command-Line Switch: -minitemheight
    • Database Name: minItemHeight
    • Database Class: MinItemHeight
  • -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, reaching from left to right of the treectrl widget, and it uses an inverting color (i.e. black on lighter background, white on darker background). This line can be used to give the user visual feedback during row resizing. iconic little helper line. ๐Ÿ”ฅ
    • Command-Line Switch: -rowproxy
    • Database Name: rowProxy
    • Database Class: RowProxy
  • -scrollmargin โ€” 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. ๐Ÿ–ฑ๏ธ
    • Command-Line Switch: -scrollmargin
    • Database Name: scrollMargin
    • Database Class: ScrollMargin
  • -selectmode โ€” 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. ๐Ÿ‘‘
    • Command-Line Switch: -selectmode
    • Database Name: selectMode
    • Database Class: SelectMode
  • -showbuttons โ€” a boolean that determines whether this widget leaves indentation space to display the expand/collapse buttons next to items. Default value is true. The item option -button determines whether an item has a button. See also the widget options -showrootbutton and -showrootchildbuttons. ๐Ÿ’–
    • Command-Line Switch: -showbuttons
    • Database Name: showButtons
    • Database Class: ShowButtons
  • -showheader โ€” a boolean that determines whether this widget should display the header line with the column names at the top of the widget. Default value is true. ๐ŸŽ€
    • Command-Line Switch: -showheader
    • Database Name: showHeader
    • Database Class: ShowHeader
  • -showlines โ€” a boolean that determines whether this widget should draw the connecting lines between related items. The default value is true on Win32 and X11, and false on Mac OS X and Gtk+. platform drama, as always. ๐ŸŒˆ
    • Command-Line Switch: -showlines
    • Database Name: showLines
    • Database Class: ShowLines
  • -showroot โ€” a boolean 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. Default value is true. โœจ
    • Command-Line Switch: -showroot
    • Database Name: showRoot
    • Database Class: ShowRoot
  • -showrootbutton โ€” a boolean that determines whether this widget leaves indentation space to display the expand/collapse button next to the root item. Default value is false. The item option -button determines whether the root item has a button. ๐Ÿฆ‹
    • Command-Line Switch: -showrootbutton
    • Database Name: showRootButton
    • Database Class: ShowRootButton
  • -showrootchildbuttons โ€” a boolean that determines whether this widget should draw the expand/collapse buttons next to children of the root item. Default value is true. ๐Ÿซถ
    • Command-Line Switch: -showrootchildbuttons
    • Database Name: showRootChildButtons
    • Database Class: ShowRootChildButtons
  • -showrootlines โ€” Database Name: showRootLines, Database Class: ShowRootLines. Bestie, this boolean decides whether the widget draws those lil connecting lines between the children of the root item. The default is true ๐Ÿ’–
  • -treecolumn โ€” Database Name: treeColumn, Database Class: TreeColumn. Specifies a column description that decides which column shows the expand/collapse buttons and the connecting lines between items. The default is unspecified โœจ
  • -usetheme โ€” Database Name: useTheme, Database Class: UseTheme. Specifies a boolean that decides whether this widget should draw parts of itself using a platform-specific theme manager. The default is true ๐Ÿ‘‘
  • -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 โ€” 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 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 โ€” 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 initial 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 โ€” 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 โ€” 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 โ€” 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 initial 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 โ€” 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 โ€” 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:

.t item id "tag {(a && !b) || (!a && b)}"

or equivalently:

.t item id "tag {a ^ b}"

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:

.t item id {tag {"a&&b"||c}}

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.

.t configure -itemtagexpr false
.t item delete "tag a&&b"

๐Ÿช„ 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 โ€” bestie, this one takes a window x-coordinate windowx inside the treectrl and translates it into canvas coordinate space. Why do you care? Because the marquee command speaks canvas coordinates and nothing else. ๐Ÿ’…
  • pathName canvasy windowy โ€” same energy, but for the y-axis: it takes windowy, a window y-coordinate in the treectrl, and translates it into canvas coordinate space. Again, marquee wants canvas coords, so here you go. ๐Ÿฆ‹
  • pathName cget option โ€” hands you back the current value of the config option named by option. And option? It can be literally any of the values that the tree command accepts. Periodt.
  • pathName collapse ?-recurse? ?itemDesc ...? โ€” Deprecated. Do not pass go, use item collapse instead. ๐Ÿ’€
  • pathName column option column ?arg ...? โ€” okay so this is the whole command for wrangling the columns of the treectrl widget (peep the COLUMNS section below ๐Ÿ‘‡). What it actually does depends on which option you hand it right after the column argument. Here's every form it supports:
    • pathName column bbox columnDesc โ€” returns a list of four elements: the bounding box of the header of the column described by columnDesc. The coordinates are relative to the top-left corner of the widget. BUT โ€” if the column has -visible=false, or the widget has -showheader=false, you get an empty list back. Sorry bestie. ๐Ÿ™ˆ
    • pathName column cget columnDesc option โ€” returns the current value of the option called option for the column described by columnDesc. Fun fact: columnDesc can also be the string tail to grab 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 but it tweaks options on the columns matching columnDesc instead of on the whole treectrl widget. columnDesc can be the string tail for the tail column. If columnDesc refers to more than one column, then you must give at least one option-value pair. If you give no option at all, it returns a list describing every available option for columnDesc (the format is described by Tk_ConfigureInfo, iykyk). If you give option with no value, you get back a list describing just that one named option โ€” and that list is identical to the matching sublist of what you'd get with no option specified. If you give one or more option-value pairs, it sets those options to those values for columnDesc and returns an empty string. ๐Ÿซถ

Hit up the COLUMNS section below for the deets on what options columns even have.

Also, for compatibility with older treectrl versions (the ones that 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 this command too. Throwback vibes. ๐Ÿ’œ

  • pathName column compare column1 op column2 โ€” for both column1 and column2, it grabs the index (exactly what column order returns). Then it compares those indexes with the operator op, which has to be one of <, <=, ==, >=, >, or !=. Returns 1 if the comparison came out true, 0 otherwise. Math is serving. ๐Ÿ”ฅ
  • pathName column count ?columnDesc? โ€” no extra args? You get a decimal string: the number of columns made by column create that haven't been deleted by column delete โ€” and heads up, the tail column is not counted here. If you do pass columnDesc, you get the number of columns matching that column description. ๐ŸŒธ
  • pathName column create ?option value ...? โ€” makes a brand new column in the treectrl widget. It goes to the right of every other column (except the tail column, obviously). Any option-value args configure the new column just like column configure would. The return value is the unique identifier of the new column โ€” treasure it. ๐Ÿ‘‘
  • pathName column delete first ?last? โ€” deletes the column(s) you point at. first and last both have to 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. ๐ŸŽ€
  • 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 columnDesc into a list of unique column identifiers. If the column(s) described by columnDesc don't exist, you get an empty list. No column, no id, no cap. โœจ
  • pathName column list ?-visible? โ€” returns a list of identifiers for every column (tail excluded, always) from left to right. If you pass -visible, only the columns whose -visible option is true show up. ๐Ÿฆ‹
  • pathName column move columnDesc beforeDesc โ€” moves the column matching columnDesc to the left of the column matching beforeDesc. Both need to be valid column descriptions. And if beforeDesc is the string tail, then columnDesc becomes the last column. Slay, reorder your life. ๐Ÿ’…
  • pathName column neededwidth columnDesc โ€” returns a decimal string: the needed width of the column matching columnDesc. The needed width is the maximum of the width of the column header and the width of the widest style in any visible item.
Heads up bestie: when an item style or a column header spans multiple columns, the needed width of a column gets affected by the widths of the other columns in the span โ€” and in that case this command's result isn't particularly useful. ๐Ÿ˜ญ
  • pathName column order columnDesc ?-visible? โ€” returns a decimal string: the position of the column matching columnDesc in the column list, starting from zero for the leftmost column. If you pass -visible, only columns whose -visible option is true get considered, and -1 comes back if columnDesc's -visible option is false. ๐Ÿ™ˆ
  • pathName column tag option ?arg arg ...? โ€” the tag-manipulation zone for columns. What it does depends on the option right after column tag. Here are the forms:
    • pathName column tag add columnDesc tagList โ€” adds every tag in tagList to the columns matching columnDesc. Duplicate tags get ignored, no drama. You can also change a column's tag list via its -tags option. ๐Ÿ’–
    • pathName column tag expr columnDesc tagExpr โ€” evaluates the tag expression tagExpr against every column matching columnDesc. Result is 1 if the tag expression is true for every column, 0 otherwise. All or nothing, bestie. ๐Ÿ”ฅ
    • pathName column tag names columnDesc โ€” returns a list of tag names assigned to the columns matching columnDesc. The result is the union of any tags assigned to those columns. ๐ŸŒˆ
    • pathName column tag remove columnDesc tagList โ€” removes every tag in tagList from the columns matching columnDesc. It is not an error if any of the columns don't use any of those tags. You can also change a column's tag list via its -tags option. ๐Ÿ“
  • pathName column width columnDesc โ€” returns a decimal string: the width in pixels of the column matching columnDesc โ€” and yes, it still does this even if the treectrl is configured to hide the column headers via the -showheader option. Iconic, honestly. โญ
  • pathName compare itemDesc1 op itemDesc2 โ€” Deprecated. Use the item compare command instead. ๐Ÿ’€
  • pathName configure ?option? ?value option value ...? โ€” query or modify the widget's configuration options. No option? You get a list describing all the available options for pathName (format per Tk_ConfigureInfo). option with no value? You get a list describing just that one named option โ€” identical to the matching sublist of the no-option version. One or more option-value pairs? It sets those widget option(s) to those value(s), and returns an empty string. And option may have any of the values the treectrl command accepts. Main character configuration energy. ๐Ÿ‘‘
  • pathName contentbox โ€” bestie this one hands you back a list of four elements, and those four cuties are the bounding box of the screen area where your items actually get displayed โœจ. It's the window area minus borders, minus column headers, minus locked columns โ€” so it's the pure vibes zone. Now if the display area has no height or no width (which happens when the window is giving way too small energy ๐Ÿ˜ญ), you get an empty string back. Also, no cap, the result of this command is literally the same as bbox content ๐Ÿ’….
  • pathName debug option ?arg arg ...? โ€” okay so this is the debugging command, and the exact behavior depends on whichever option comes right after debug. Here's every form it supports:
    • pathName debug alloc โ€” returns a string with partial statistics on memory allocations, but only if the package was built with TREECTRL_DEBUG defined. Otherwise it's giving nothing, bestie ๐Ÿซถ.
    • pathName debug cget option โ€” returns the current value of the debugging option named option. option may have any of the values accepted by the debug configure widget command.
    • pathName debug configure ?option? ?value? ?option value ...? โ€” this one is like the configure widget command, except it messes with debugging options instead of the overall treectrl widget options. If you pass no option, it returns a list describing all available debugging options (see Tk_ConfigureInfo for the format deets). If you pass option with no value, you get a list describing just that one named option โ€” and that list is identical to the matching sublist you'd get from the no-option call. And if you pass one or more option-value pairs, it modifies those debugging option(s) to the given value(s), and returns an empty string in that case.

These are the debugging options it supports:

  • -displaydelay millis โ€” specifies a time duration in milliseconds that should be waited after something has been drawn to the screen. Setting this only does anything if the debugging options -enable and -display are switched on, periodt.
  • -data boolean โ€” if this is switched on (together with the debugging option -enable), then at various places a consistency check gets run on the internal data structure โ€” like, for every item it checks whether the registered number of children equals the number of child items ๐Ÿ‘€. If an inconsistency is found, a Tcl background error is raised.
  • -display boolean โ€” if switched on (together with -enable), then at various places additional debugging output gets printed to stdout. It's giving spam, but the helpful kind ๐Ÿ’–.
  • -drawcolor color โ€” when specified, areas of the window are painted with this color when drawing in those areas is about to occur. Only has an effect if -enable and -display are switched on.
  • -enable boolean โ€” all the other debugging options only take effect if this one is also switched on. It's the main character of debugging options, fr fr ๐Ÿ‘‘.
  • -erasecolor color โ€” when specified, areas of the window marked as "invalid" (like when part of the window is exposed) get painted with this color. If you use an unusual color here (like pink), superfluous screen redraws are way easier to spot ๐Ÿ˜Œ. Only has an effect if -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 โ€” causes the area of the window bounded by the given window-coords to be marked as invalid. Basically it simulates uncovering part of the window ๐Ÿฆ‹.
  • pathName depth ?itemDesc? โ€” if you hand it the extra argument itemDesc, the result is a decimal string giving the depth of the item described by itemDesc. If you don't pass itemDesc, then you get the maximum depth of all items in the treectrl widget instead. And depth is defined as the number of ancestors an item has โ€” no more, no less โœจ.
  • pathName dragimage option ?arg ...? โ€” this command manipulates the drag image, which is the thing that gives feedback when items are drag-and-dropped inside the window. The drag image shows up as dotted outlines of one or more items, columns and/or elements. Exact behavior depends on the option right after dragimage. Here's every form:
    • pathName dragimage add itemDesc ?column? ?element? โ€” adds the shapes of the item described by itemDesc to the shapes of the dragimage. Specifying extra arguments reduces the number of rectangles added. If you pass no extra args, then for every element of the item in every column a dotted rectangle gets added. If column is specified, all elements in other columns are ignored. And if element is specified too, only a rectangle for that one element of the specified item in the given column gets added ๐ŸŽ€.
    • pathName dragimage cget option โ€” returns the current value of the dragimage option named option. option may have any of the values accepted by the dragimage configure widget command.
    • pathName dragimage clear โ€” removes all shapes (if there are any) from the dragimage. Note: this command does not modify the dragimage offset ๐Ÿ’….
    • pathName dragimage configure ?option? ?value? ?option value ...? โ€” same deal as the configure widget command, but it modifies dragimage options instead of the overall treectrl widget options. No option given? You get a list describing all available dragimage options (format deets in Tk_ConfigureInfo). option with no value? You get a list describing that one named dragimage option, identical to the matching sublist from the no-option call. One or more option-value pairs? It modifies those dragimage option(s) to the given value(s), returning an empty string ๐ŸŒธ.

The dragimage option it supports:

  • -visible boolean โ€” specifies a boolean value which determines whether the dragimage should currently be visible. Iconic.
  • pathName dragimage offset ?x y? โ€” with no extra args, returns a list containing 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. If you pass two coordinates, it sets the dragimage offset to the given coordinates x and y โœจ.
  • pathName element option ?element? ?arg arg ...? โ€” this command manipulates elements (peep ELEMENTS AND STYLES below for the full tea). Exact behavior depends on the option right after 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 may have any of the values accepted by the element configure widget command.
Also, heads up: this command also accepts the -statedomain option ๐Ÿ’–.
  • pathName element configure element ?option? ?value? ?option value ...? โ€” like the configure widget command, except it modifies options associated with the element given by element instead of the overall treectrl widget options. No option? You get a list describing all available options for element (see Tk_ConfigureInfo for the format). option with no value? You get a list describing that one named option, identical to the corresponding sublist from the no-option call. One or more option-value pairs? It modifies those option(s) to the given value(s) in element, and returns an empty string. Peep ELEMENTS AND STYLES below for the deets on the options available for elements ๐Ÿฆ‹.

okay so we're still deep in WIDGET COMMAND and now we're hitting the element, gradient and header subcommands โ€” hydrate bestie, this one's a whole journey ๐Ÿ’งโœจ

  • pathName element create name type ?option value ...? โ€” makes a brand-new master element of type type with the unique, user-defined name name, and sets it up with zero or more option/value pairs. Wanna know which options fly for which type? Go read the subsections on each individual element type over in ELEMENTS AND STYLES. This command hands back the name of the new element โ€” which is literally the same thing as the name argument, no plot twist. ๐Ÿ‘‘

It also accepts the -statedomain option, and the value is either header or item, which tells you where this element is gonna be displayed. periodt.

  • pathName element delete ?element ...? โ€” deletes every one of the named elements and returns an empty string. Heads up though: 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. it's giving cleanup crew ๐Ÿงน
  • pathName element names โ€” returns a list holding the names of all the elements that currently exist.
  • pathName element perstate element option stateList โ€” returns the value of the per-state option named option for element, for one specific state. stateList is a list of state names โ€” both static and dynamic, peep STATES โ€” and it's what picks which state to use.
  • pathName element type element โ€” returns the type of the element you passed in, like rect or text. so simple, so iconic ๐Ÿ’…

  • pathName expand ?-recurse? ?itemDesc ...? โ€” Deprecated. Use item expand instead. that's it, that's the whole note ๐Ÿ™ˆ

๐ŸŒˆ gradient ๐ŸŒˆ

  • pathName gradient option ?arg ...? โ€” this is the command for manipulating color gradients. Need the full lore? Check GRADIENTS. What it actually does depends on the option argument sitting right after gradient. These are the supported forms, bestie:

gradient cget

  • pathName gradient cget gradient option โ€” returns the current value of the configuration option, for the gradient named by gradient, whose name is option. And option can be any of the values that the gradient configure command accepts. โœจ

gradient configure

  • pathName gradient configure gradient ?option value ...? โ€” okay so:
    • no option given โ†’ returns a list describing all the available gradient options (for the format of that list, see Tk_ConfigureInfo).
    • option given with no value โ†’ returns a list describing that one named gradient option (and that list will be identical to the matching sublist of the value you'd get with no option at all).
    • one or more option-value pairs given โ†’ it modifies the given gradient option(s) to hold the given value(s), and in that case the command returns an empty string.

These are the options it supports (for what each one means, go see gradient create):

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

gradient create

  • pathName gradient create name ?option value ...? โ€” creates a new gradient named name, and name has to be unique โ€” no other gradient made by this treectrl widget can already be using it. The supported options:
    • -bottom coordSpec
    • -left coordSpec
    • -right coordSpec
    • -top coordSpec โ€” each of these specifies one edge of the gradient brush. If you set it to an empty string (which is the default), the gradient brush's edge is the same as the edge of whatever rectangle is being painted with the gradient. For the deets on gradient brush coordinates, see GRADIENT 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 โ€” sets the direction a linear gradient changes color in. Gotta be either horizontal (that's the default) or vertical, or an abbreviation of one of those.
    • -steps stepCount โ€” how many bands of color get drawn for each color stop described by the -stops option. Default is 1, max 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 that.
    • -stops stopsList โ€” the color stops along this gradient. The stopsList argument looks like this:
{{offset color ?opacity?} {offset color ?opacity?} ...}

Every offset is a floating point number from 0.0 to 1.0 marking the distance from the start of the gradient where that color begins. Every color is a Tk color name or description. Every optional opacity is a floating point number from 0.0 to 1.0 saying how transparent the gradient is. And ngl the rules are strict here:

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.

Also: specifying opacity has no effect if gradients are drawn using Tk API calls. See GRADIENTS for more on that. ๐Ÿ’€

gradient delete

  • pathName gradient delete ?name ...? โ€” deletes each gradient named by name. But plot twist: if the gradient is still being used, it's not actually deleted until every element etc. that's using it has stopped. And a deleted-but-in-use gradient is not recognized by the various gradient commands. Now here's the slay part: if you create a new gradient with the same name as a deleted-but-in-use gradient, it resurrects the deleted gradient. ๐Ÿ’…โœจ

gradient names

  • pathName gradient names โ€” returns a list of the names of all the gradients that have been created by this treectrl widget.

gradient native

  • pathName gradient native ?preference? โ€” with no arguments at all, this returns a boolean saying whether or not the platform supports native transparent gradients. The preference argument is a boolean that says whether native gradients should be used โ€” handy for testing out how the application looks. ๐Ÿฆ‹

  • pathName header option ?arg ...? โ€” this one is for manipulating column headers. What it does depends on the option argument right after header. These are the supported forms, bestie:
  • pathName header bbox headerDesc ?column? ?element? โ€” see the item bbox command.
  • pathName header compare headerDesc1 op headerDesc2 โ€” see the item compare command.
  • pathName header configure headerDesc ?arg ...? โ€” there are two forms of this, and which one you get depends on whether or not a column description shows up after the headerDesc argument. If the first argument after headerDesc begins with a - character, it's assumed to be an option name and 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 ...?
      • no option given โ†’ returns a list describing all the available options for the header given by headerDesc (see Tk_ConfigureInfo for the format of that list).
      • option given with no value โ†’ returns a list describing that one named option (identical to the corresponding sublist of the value you'd get if no option were specified).
      • one or more option-value pairs given โ†’ modifies the given option(s) to hold the given value(s), and the command returns an empty string. And this right here is the only case where headerDesc may refer to multiple header-rows. ๐Ÿ™ˆ

These are the options this command supports (see header create for what each one means):

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

๐ŸŽ€ pathName header configure โ€” the column glow-up command

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

Okay bestie, this is where you customise one specific column inside one specific header-row. Here's the tea:

  • If you pass no option, you get back a list describing all the available options for the single column column of the header-row given by headerDesc. (Peep Tk_ConfigureInfo if you wanna know what that list's format even looks like.)
  • If you pass option but no value, you get a list describing just that one named option. And this list is literally identical to the matching sublist of the big list you'd get with no option at all. Same vibe, smaller serving. โœจ
  • If you pass one or more option-value pairs, the command changes those option(s) to those value(s) and returns an empty string. And heads up: this is the only case where headerDesc may refer to multiple header-rows and column may refer to multiple header-columns. So it's the one glow-up that can hit a whole crowd at once. ๐Ÿ’…

Here's every option this command supports (run to 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 โ€” how many rows we got

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 gets created right along with the widget. She's always there, she's not going anywhere. ๐Ÿ‘‘

But if you hand it the optional headerDesc, the result flips to: how many header-rows match that header description. Filtered count, periodt.


๐ŸŒฑ pathName header create โ€” birth a new header-row

pathName header create ?option value?

Makes a brand-new header-row and returns its unique identifier. Slay. These are the config options:

  • -height height โ€” sets a fixed height for the header-row, in any of the forms acceptable to Tk_GetPixels. 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. The header tag command can also be used to manipulate this list of tags. Tag her up, bestie. ๐Ÿท๏ธ
  • -visible boolean โ€” boolean must be one of the forms accepted by Tcl_GetBoolean. It says whether or not the header-row should be displayed. But plot twist: if the widget option -showheader is false, then the header-row will not be displayed regardless of what this option says. No amount of -visible true is gonna fix that. ๐Ÿ˜ญ

๐Ÿ—‘๏ธ pathName header delete โ€” bye bestie

pathName header delete headerDesc

Deletes the header-rows given by the header description headerDesc. And here's the safety net: attempts to delete the ever-present top header-row are just ignored, without raising an error. She cannot be deleted. She is eternal. ๐Ÿ’€


๐Ÿ–๏ธ pathName header dragcget โ€” read the drag-and-drop settings

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:

  • If the first argument begins 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 begin with a '-', it's assumed to be a header description โ€” so the command applies to a header-row.

๐Ÿงธ pathName header dragcget option

pathName header dragcget option

Returns the current value of the header-drag-and-drop option named option for the widget. Supported options (see 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

pathName header dragcget headerDesc option

Returns the current value of the header-drag-and-drop option named option for a header-row. Supported options (again, see header dragconfigure for the meaning of each):

  • -draw boolean
  • -enable boolean

๐Ÿ› ๏ธ pathName header dragconfigure โ€” set the drag-and-drop settings

pathName header dragconfigure ?arg ...?

Same two-form situation as dragcget, bestie:

  • First argument begins with '-' โ†’ it's an option name, not a header description โ†’ applies to the header-drag-and-drop options for the widget.
  • First argument does not begin with '-' โ†’ it's a header description โ†’ applies to a header-row.

๐ŸŒˆ pathName header dragconfigure ?option? ?value? ?option value ...?

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, and yes we're going through all of them:

  • -enable boolean โ€” Controls whether the user is allowed to rearrange columns by drag-and-drop. The default is false. And FYI, each header-row also has its own -enable dragconfigure option.
  • -imagealpha alpha โ€” alpha is an integer from 0 (invisible) to 255 (opaque) controlling the transparency of the drag image. Any value outside this range gets clipped. The 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 ...?

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

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

  • -draw boolean โ€” Controls whether a header-row displays any feedback during header drag-and-drop. The default is true.
  • -enable boolean โ€” Controls whether clicking and dragging in this header-row initiates drag-and-drop. The default is true. But: if the -enable option for the widget is false (see above), then this option has no effect. Widget says no, row says nothing. ๐Ÿซถ

๐Ÿงฉ pathName header element

pathName header element ?arg ...?

See the item element command. That's it, that's the whole thing. โœจ


๐Ÿ†” pathName header id

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 this command returns an empty list. No drama, just vibes. ๐Ÿฆ‹

  • pathName header image headerDesc ?column? ?image? ?column image ...? โ€” okay so this one's a lil shapeshifter depending on your column header's vibe. If the column header got no style, or a style with no image element in it, then this just messes with the same -image option as header configure. But if it does have an image element in its style, then it operates on the -image option of the first image element in that column header's style. See the item image command for the deets. ๐Ÿ’…
  • pathName header span headerDesc ?column? ?numColumns? ?column numColumns ...? โ€” just go peep the item span command, it's the same energy.
  • pathName header state command headerDesc ?arg ...? โ€” same as the item state command, bestie.
  • pathName header style command headerDesc ?arg ...? โ€” yep, this is the item style command's twin.
  • pathName header text headerDesc ?column? ?text? ?column text ...? โ€” same situation as image up there but for text, obvi. If the column header has no style, or no style containing a text element, this operates on the same -text option as header configure. Otherwise it operates on the -text option of the first text element in the column header's style. Peep item text. โœจ
  • pathName header tag command headerDesc ?arg ...? โ€” literally just the item tag command, go look.

๐Ÿ” pathName identify ?-array varName? x y

This one tells you what's actually sitting at the window coordinates x and y. So if you pass the -array option with a variable name, it fills up the array variable's elements like this:

  1. If the coords are outside the window, over the borders, or over any whitespace in the window, then:
    • $varName(where) is ""
  2. If the coords 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 coords 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 what's used to collapse the ancestor when the line gets clicked on. ๐Ÿซถ

When you don't use -array, this command returns a list describing what's displayed at those coordinates instead. The format of that list can be one of these:

  1. {} An empty list comes back 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?

The unique id of a header-row `H` followed by the keyword `column` only shows up when there's **more than one** header-row. That's for compatibility with older versions, back when only one row of column headers was allowed. ๐Ÿ‘‘

3. `item I column C`

4. `item I column C elem E`

5. `item I button`
This is what you get when the coordinates are over the expand/collapse button next to an item.

6. `item I line I2`
This is what you get when the coordinates are over a line descending from an ancestor `I2` of the item `I` (but not the parent of that item). Used to collapse the ancestor when the line gets clicked on.

---

- **`pathName index itemDesc`** โ€” <red>Deprecated.</red> Use `item id` instead. fr fr, it's giving legacy code energy. ๐Ÿ’€

---

## ๐ŸŽ€ `pathName item option ?arg ...?`

This is the one you use to mess with items. What it actually does depends on the `option` argument that comes right after `item`. Here's every form it supports:

- **`pathName item ancestors itemDesc`** โ€” Returns a list of the item ids of the ancestors of the item given by `itemDesc`. First value in the list is the parent, 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 itemDesc ?column? ?element?`** โ€” Returns a list of four elements, the bounding box of the item described by `itemDesc`. No extra args? The bbox spans the area of the item over **all non-locked columns**. Specify a column and only that column's area of the item counts. Specify an element on top of that and you get the area of that element in that column of that item. Returned coordinates are relative to the top-left corner of the widget. If the item isn't visible for literally any reason, you get an empty string. ๐Ÿ˜ญ

- **`pathName item buttonstate itemDesc ?state?`** โ€” Give it a `state` and it sets the state of the expand/collapse button for that one single item given by `itemDesc`. `state` can be `active`, `normal` or `pressed`. The current (or newly-set) state of the button gets returned. The button state is what the system theme (if there is one) uses to change how the button looks. โœจ

- **`pathName item cget itemDesc option`** โ€” Returns the current value of the config option named `option` for the item given by `itemDesc`. `option` can be any of the values that the `item configure` command accepts.

- **`pathName item children itemDesc`** โ€” Returns a list of the item ids of **all** the children of the item given by `itemDesc`, in the correct order from first child to last child. ๐Ÿฆ‹

- **`pathName item collapse itemDesc ?-animate? ?-recurse?`** โ€” Switches **off** the open state of the item(s) described by `itemDesc`. If an item has descendants, they stop being displayed. If an item is already closed, this command does nothing to it. If `-animate` is given, the item's button animates as it transitions between states (if the theme supports it) โ€” and in that case only **one** item may be specified. If `-recurse` is given, all descendants of the items described by `itemDesc` also get collapsed. For every item that actually *will* be collapsed, two events fire: a `<Collapse-before>` event before the item state changes, and a `<Collapse-after>` event after the state changed. ๐Ÿ”ฅ

- **`pathName item compare itemDesc1 op itemDesc2`** โ€” Grabs the index from both items described by the itemDescs (as returned by the `item order` widget command). Then compares those indexes using the operator `op`, which has to be one of `<`, `<=`, `==`, `>=`, `>` or `!=`. Returns `1` if the comparison was true, `0` otherwise. ๐Ÿ’…

- **`pathName item complex itemDesc ?list...?`** โ€” <red>This horrible command is now deprecated.</red> Use `item element configure` instead. For every column of the treectrl there may be one list specified. Each list should look like this:

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


Every option has to be known by the element's type (see **ELEMENTS AND STYLES** below). Each option gets set to `value` for the element in this one column in this item. Not me warning you that it's literally called "horrible" in the source. ๐Ÿ™ˆ

- **`pathName item configure itemDesc ?option? ?value? ?option value ...?`** โ€” No `option` given? Returns a list describing all the available options for the item given by `itemDesc` (see `Tk_ConfigureInfo` for what that list's format looks like). Give an `option` with no `value` and it returns a list describing just that one named option (this list is identical to the corresponding sublist of the value you'd get with no option specified).

Give one or more `option-value` pairs and it modifies those item option(s) to have the given value(s); in that case the command returns an empty string. And **this is the only case** where `itemDesc` may refer to multiple items. ๐Ÿ‘‘

Here are the options this command supports (see `item create` for what each one means):

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

- **`pathName item count ?itemDesc?`** โ€” No extra args? You get a decimal string, the number of items created by the `item create` widget command that haven't been deleted by the `item delete` widget command, **plus 1** for the ever-present root item. Give the optional `itemDesc` argument and you get the number of items that match that item description instead. ๐Ÿ“

### <pink>`pathName item create ?option value ...?` ๐Ÿ’–</pink>

Okay bestie, this is the one that actually makes items exist. It creates some new items, and optionally hands you back a list of unique identifiers for those items. The new items come out of the box with the states `open` and `enabled` switched on by default. And if the treectrl widget currently has the focus? Yeah, the state `focus` gets set too. Iconic. ๐Ÿ‘‘

Here are all the options this command vibes with:

- **`-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). It says whether an expand/collapse button should be drawn next to the item โ€” typically to hint that the item has children. If the value is `auto`, then a button shows up next to the item whenever the 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.
- **`-count numItems`** โ€” how many items you want to create. Must be `>= 0`. Defaults to `1`.
- **`-enabled boolean`** โ€” says whether the items should be enabled. Default is `true`.
- **`-height height`** โ€” 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`. Peep the widget options `-itemheight` and `-minitemheight` too.
- **`-nextsibling itemDesc`** โ€” names the item *before* which the new items get inserted. The new items will have the same parent as *itemDesc*.
- **`-open boolean`** โ€” whether the items should be open or closed. Default is `true`.
- **`-parent itemDesc`** โ€” names the item that the new items become children of. The new items get appended to the list of children of *itemDesc*. When no parent is specified, the new items are orphan items (go look at the widget command `orphans`) and will not be displayed in the list.
- **`-prevsibling itemDesc`** โ€” names the item *after* which the new items get inserted. The new items will have the same parent as *itemDesc*.
- **`-returnid boolean`** โ€” whether or not to return a list of item identifiers for the newly created items. Specifying `false` is useful when you're creating a huge number of items in the console, or just want better 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 says 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 says this item should be the first one in a horizontal range or vertical range of items. See also the widget option `-wrap`.

---

### <hotpink>`pathName item delete first ?last?` ๐Ÿ’€</hotpink>

Bye bye, items. This 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* gets deleted. The order of *first* and *last* doesn't matter, no cap.

Deleting an item deletes any child items of the deleted item **recursively**. If the current active item gets deleted, the root item becomes the new active item. If the current selection anchor item gets deleted, the root item becomes the new anchor item. And there is <red>no way</red> to delete the root item of the treectrl widget โ€” in all cases the specification of the root item is just ignored. ๐Ÿซถ

For each call to this command, two events may be generated. If any of the deleted items are selected, then they're 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.

### <purple>`pathName item descendants itemDesc` ๐ŸŒธ</purple>

Returns a list containing the item ids of the descendants of the item specified by *itemDesc* โ€” like, the children, grandchildren, great-grandchildren etc, of the item. The whole family tree, fr fr.

### <cyan>`pathName item dump itemDesc` ๐Ÿฆ‹</cyan>

Debug command, bestie. Returns a list with 4 words in the form `index index indexVis indexVis`.

### <mint>`pathName item element command itemDesc column element ?arg ...?` โœจ</mint>

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

#### <lavender>`pathName item element actual itemDesc column element option`</lavender>

<red>Deprecated.</red> Use `item element perstate` instead.

#### <lavender>`pathName item element cget itemDesc column element option`</lavender>

This one 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).

#### <lavender>`pathName item element configure itemDesc column element ?option? ?value? ?option value ...?`</lavender>

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 info 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.

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:

.t item element configure $I \ $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.

#### <lavender>`pathName item element perstate itemDesc column element option ?stateList?`</lavender>

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.

### <peach>`pathName item enabled itemDesc ?boolean?` ๐Ÿ“</peach>

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 <red>cannot be selected</red>, and are ignored by the default key-navigation and mouse bindings. ๐Ÿ™ˆ

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


Switches the <pink>open</pink> state ON for the item(s) described by *itemDesc*. If an item has descendants, bestie, they're now showing up on screen ๐Ÿ’–. If it's already open, this command literally does nothing to it โ€” no double-toggle, no drama. If `-animate` is passed, the item's button will animate as it flips between states **if the theme supports it** โ€” and heads up, in that case you can only specify <hotpink>one</hotpink> item. If `-recurse` is passed, every descendant of the items described by *itemDesc* also gets expanded. For every item that actually gets expanded, <purple>two events</purple> fire: an `<Expand-before>` event *before* the item state changes, and an `<Expand-after>` event *after* the state changed. Iconic event choreography, no cap ๐ŸŽ€.

---

pathName item firstchild parent ?child?


If *child* isn't specified, this hands you back the item id of the <mint>first child</mint> of the item described by *parent*. 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 brand-new first child of *parent*. Glow-up order change โœจ.

---

pathName item id itemDesc


This resolves the item description *itemDesc* into a list of <cyan>unique</cyan> item identifiers. If *itemDesc* doesn't point at any existing items, you just get an empty list back. Crickets ๐Ÿฆ—.

---

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


Sets or retrieves the value of the per-state `-image` option for the <pink>first image element</pink> in one or more columns. If no *column* is specified, this returns a list of values, one per column ๐ŸŒธ. If no *image* is specified, it returns the value for *column*.

If one or more *column*-*image* pairs are specified, then the `-image` option in each column gets set to *image*. In that case *itemDesc* may refer to <hotpink>multiple items</hotpink> and each column may refer to <hotpink>multiple columns</hotpink>. Multi-tasking queen ๐Ÿ’….

> Ngl, this command is provided as a convenience. Use the `item element configure` or `item element cget` commands if you want to set or retrieve the value of the `-image` option for a **specific** image element. 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, the original spells it "decribed" โ€” we're keeping the family tree exactly as it is ๐Ÿ™ˆ.)

---

pathName item isopen itemDesc


Returns `1` if the item described by *itemDesc* has the `open` state switched on, `0` otherwise. Vibe check: is it open or not ๐Ÿ’–.

---

pathName item lastchild parent ?child?


If *child* isn't specified, returns the item id of the <mint>last child</mint> 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*. No cap.

---

pathName item nextsibling sibling ?next?


If *next* isn't specified, returns 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 whole friend group ๐Ÿ”ฅ.

---

pathName item order itemDesc ?-visible?


This returns the position of the item *itemDesc* relative to its <purple>toplevel ancestor</purple> โ€” usually the root item, unless that ancestor is an orphan. Picture all the items flattened into one long vertical list, and the result is the row your item falls in ๐ŸŽ€.

If the optional `-visible` argument is given, only the items whose ancestors are expanded, **and** whose `-visible` option is true, get counted. In that case `-1` is returned if the item isn't visible. Not me getting excluded from the count ๐Ÿ˜ญ.

---

pathName item parent itemDesc


Returns the item id of the parent of the item described by *itemDesc*. Who's your mother, fr fr.

---

pathName item prevsibling sibling ?prev?


If *prev* isn't specified, returns 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*. Sibling lore, but make it backwards ๐Ÿ’œ.

---

pathName item range first last


Returns a list containing the item ids of <hotpink>all</hotpink> items in the range between *first* and *last*, inclusive. The order between *first* and *last* doesn't matter, and the result is **always** sorted by the increasing order of the items โ€” as returned by the `item order` command. And important: the items specified by *first* and *last* must share a <rainbow>common ancestor</rainbow> ๐ŸŒˆ.

---

pathName item remove itemDesc


Removes the item described by *itemDesc* from the list of children of its parent, so that it becomes an <purple>orphan</purple>. Main character goes solo ๐Ÿ˜ญโœจ.

---

pathName item rnc itemDesc


Returns a list of two integers, which corresponds to the <mint>row</mint> and <mint>column</mint> 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 isn't displayed, this command returns an empty string. Ghosted ๐Ÿซฅ.

---

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 ๐Ÿ”ฅ.

The range of items that should be sorted can be restricted with 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; this option can be used <pink>repeatedly</pink> to define a multicolumn sort. The sorting is done 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 the `-notreally` option is specified, no rearranging of the items is done; instead the sorted items are returned as the result of the command. Sneaky peek energy ๐Ÿ™ˆ.

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 <cyan>previously specified</cyan> 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 sets or retrieves the <mint>number of columns</mint> that a style covers. If no *column* is specified, the return value is a list of spans, one per column ๐ŸŒธ. If no *numColumns* is 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. Multitasking, obsessed ๐Ÿ’….

---

pathName item state command itemDesc ?arg ...?


This command is used to manipulate the <purple>states</purple> 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. No duplicates allowed bestie ๐Ÿ™…โ€โ™€๏ธ.

pathName item state forcolumn itemDesc column ?stateDescList?


Just like `item state set` but manipulates dynamic states for a <hotpink>single item column</hotpink>, 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. Slay ๐ŸŽ€.

- **`pathName item state get itemDesc ?stateName?`** โ€” okay so if you don't hand it a *stateName*, it hands you back a list of literally every state (static AND dynamic, both of them ๐Ÿ’–) that's currently switched **on** for the item that *itemDesc* is describing. But if you *do* pass a *stateName*? Then it gives you `1` if that state is currently switched on for the item, and `0` if it's not. Simple as. โœจ

- **`pathName item state linkage stateName`** โ€” this one returns a string telling you whether the *stateName* you gave is **user-defined** (meaning it came from the `item state define` widget command โ€” that's what we call *dynamic*) or whether it was **predefined by the `treectrl` widget itself** (that's *static*). no cap.

- **`pathName item state names`** โ€” returns a list of the names of all the user-defined states. that's it, that's the whole vibe ๐ŸŽ€

- **`pathName item state set itemDesc ?lastItem? stateDescList`** โ€” every single element of *stateDescList* has to be the name of a **dynamic state** (peep **STATES** below for that ๐Ÿ‘€), and it can optionally be preceded by a `~` or a `!` character. Here's the tea:
  - any state with a leading `!` gets switched **off** for the item described by *itemDesc*
  - any state with a leading `~` gets **toggled**
  - any state with no leading `!` or `~` gets switched **on**

  If *lastItem* is specified, then those state changes get made for **all** the items in the range between *itemDesc* and *lastItem*. If *lastItem* is unspecified, then the state changes get made for all items described by *itemDesc*. ๐Ÿ’…

- **`pathName item 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 bestie ๐Ÿ‘‹

- **`pathName item style command itemDesc ?arg ...?`** โ€” this command is your go-to for manipulating the styles of an item. The exact behavior depends on the *command* argument that follows the `style` argument, so let's get into the supported forms:

  - **`pathName item style elements itemDesc column`** โ€” returns a list with the names of elements that were configured by the `item element configure` command for the item described by *itemDesc* in *column*. โš ๏ธ If there's **no style assigned** to *column*, an error gets returned. rude but fair.

  - **`pathName item style map itemDesc column style map`** โ€” just like the `item style set` command, this can assign a style to a specific column of an item. But *unlike* `item style set`, this one can **transfer configuration values** of elements in the current style over to elements in the new style specified by *style*. ๐Ÿฆ‹ *map* has to 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 of the same type** (`bitmap`, `text` etc). *itemDesc* may refer to multiple items and *column* may refer to multiple columns. iconic.

  - **`pathName item style set itemDesc ?column? ?style? ?column style ...?`** โ€” sets or retrieves the style assigned to one or more columns.
    - if no *column* is specified โ†’ returns a list with the names of the styles set for **all** columns of the item described by *itemDesc*
    - if no *style* is specified โ†’ returns the name of the style set for the item described by *itemDesc* in *column*
    - if one or more *column*-*style* pairs are specified โ†’ the style in each column gets set to *style*. In that case, *itemDesc* may refer to multiple items and each *column* may refer to multiple columns. slay ๐Ÿ’…

- **`pathName item tag option ?arg arg ...?`** โ€” this one's for manipulating tags on items. The exact behavior depends on the *option* argument that follows the `item tag` argument. Forms:

  - **`pathName item tag add itemDesc tagList`** โ€” adds each tag in *tagList* to the items specified by the item description *itemDesc*. Duplicate tags get ignored (we don't do repeats ๐Ÿšซ). psst โ€” the list of tags for an item can *also* be changed via an item's `-tags` option.

  - **`pathName item tag expr itemDesc tagExpr`** โ€” evaluates the tag expression *tagExpr* against **every** item specified by the item description *itemDesc*. Result is `1` if the tag expression evaluates to true for every item, and `0` otherwise.

  - **`pathName item tag names itemDesc`** โ€” returns a list of tag names assigned to the items specified by the item description *itemDesc*. The result is the **union** of any tags assigned to the items. โœจ

  - **`pathName item tag remove itemDesc tagList`** โ€” removes each tag in *tagList* from the items specified by the item description *itemDesc*. It is **not an error** if any of the items don't use any of the tags โ€” so don't stress ๐Ÿซถ. And again, the list of tags for an item can also be changed via an item's `-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.
  - if no *column* is specified โ†’ returns a list of values, one per column
  - if no *text* is specified โ†’ returns the value for *column*
  - if one or more *column*-*text* pairs are specified โ†’ the value of the `-text` option in each column gets set to *text*. In that case, *itemDesc* may refer to multiple items and each *column* may refer to multiple columns.

  > Heads up bestie ๐Ÿ’– this command is literally just a convenience. If you wanna set or retrieve the value of the `-text` option for a **specific** text element, use the `item element configure` or `item element cget` commands instead. iykyk.

- **`pathName item toggle itemDesc ?-animate? ?-recurse?`** โ€” changes the **open state** of the item(s) described by *itemDesc*. If the open state is currently switched off, this command does the same thing as the `item expand` widget command; otherwise it does the same as the `item collapse` widget command. ๐ŸŒ€
  - if `-animate` is specified โ†’ the item's button will animate as it transitions between states **if the theme supports it**; and in that case, **only one item may be specified**
  - if `-recurse` is specified โ†’ the open state of **all descendants** of the items described by *itemDesc* will also be toggled

---

- **`pathName marquee option ?arg ...?`** โ€” this command manipulates the **marquee**, which you can use to implement a resizable selection rectangle (in a file browser, for example ๐Ÿ‘€). One corner point of the marquee is 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 the marquee and it's simply called the **corner**.

  Okay so all the coordinates this widget command handles are **canvas coordinates**, meaning you should use the `canvasx` or `canvasy` widget command to translate window coordinates into canvas coordinates. don't skip that step ๐Ÿซถ

  By default, the marquee is displayed as a **1-pixel thick dotted rectangle**. But if *either* of the `-fill` or `-outline` options is specified, then the marquee gets drawn as a **filled and/or outlined rectangle** of the specified color(s). The `-fill` option should specify a **transparent gradient** so you don't hide what's inside the marquee. See **GRADIENTS** for more info. ๐ŸŒˆ

  The exact behavior of the command depends on the *option* argument that follows the `marquee` argument. Forms:

  - **`pathName marquee anchor ?x y?`** โ€” returns a list containing the `x` and `y` coordinates of the anchor, if no additional arguments are specified. If two coordinates are specified, it 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* may have any of the values accepted by the `marquee configure` widget command.

  - **`pathName marquee configure ?option? ?value? ?option value ...?`** โ€” just like the `configure` widget command, except this one modifies the **marquee** options instead of modifying options for the overall `treectrl` widget. ๐ŸŽ€
    - if no *option* is specified โ†’ returns a list describing **all** the available marquee options (see `Tk_ConfigureInfo` for info on the format of this list)
    - if *option* is specified with no *value* โ†’ returns a list describing that one named marquee option (this list will be identical to the corresponding sublist of the value returned when no *option* is specified)
    - if one or more *option*-*value* pairs are specified โ†’ 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. ๐Ÿ’–

More marquee config knobs, bestie โ€” we're still in `marquee configure` territory:

- **`-outline`** *color* โ€” the color used to outline the marquee rectangle. That's it, that's the whole job. ๐ŸŽ€

- **`-outlinewidth`** *color* โ€” how wide the outline drawn *inside* the marquee's rectangle is. If this value is less than `1`, no outline gets drawn, periodt. <red>Also important:</red> this option does **nothing** if `-outline` isn't specified โ€” the default dotted rectangle is completely unaffected by it. `outlineWidth` can be in any of the forms acceptable to `Tk_GetPixels`. Defaults to `1`.

- **`-visible`** *boolean* โ€” a boolean value that decides whether the marquee is displayed at all. Vibe check for your selection box. โœจ

---

### <pink>**`pathName marquee coords ?x1 y1 x2 y2?`**</pink>

With no extra arguments, this hands you back a list containing the x and y coordinates of the anchor, followed by the x and y coordinates of the corner. If you pass four coordinates, it sets the anchor to `x1` and `y1` and the corner to `x2` and `y2`. ๐Ÿฆ‹

### <pink>**`pathName marquee corner ?x y?`**</pink>

No extra args? You get a list with the x and y coordinates of the corner. Give it two coordinates and it sets the corner to `x` and `y`. Slay. ๐Ÿ’…

### <pink>**`pathName marquee identify`**</pink>

Returns a list with info about any items intersecting the marquee. The format of the returned list is:

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


<yellow>Two lil' gotchas to keep in your notes app:</yellow> there may be **zero** sublists following an item id if the marquee is 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. Not me warning you twice โ€” it's giving thorough. ๐Ÿ’€

---

## <rainbow>**`pathName notify option ?arg ...?`**</rainbow>

Okay so this is the big one, and it's genuinely iconic. Many Tk widgets communicate with the outside world via `-command` callbacks and/or virtual events. Like, for example, the Text widget evaluates its `-yscrollcommand` when the view in the widget changes, and generates a `<<Modified>>` virtual event when text is inserted or deleted.

A treectrl widget **replaces both methods** of communication with its own event mechanism, and you access it through the `notify` subcommands. Main character energy fr fr. ๐Ÿ‘‘

The exact behavior of the command depends on the option argument that follows the `notify` argument. The following forms of the command are supported:

### <purple>**`pathName notify bind ?object? ?pattern? ?+??script?`**</purple>

This command associates Tcl scripts with events generated by a treectrl widget. If all three arguments are specified, `notify bind` will arrange for `script` (a Tcl script) to be evaluated whenever the event(s) specified by `pattern` are generated by this treectrl widget. If `script` is prefixed with a `+`, then it is **appended** to any existing binding for `pattern`; otherwise `script` **replaces** any existing binding. If `script` is an empty string then the current binding for `pattern` is destroyed, leaving `pattern` unbound. In all of the cases where a `script` argument is provided, `notify bind` returns an empty string.

If `pattern` is specified without a `script`, then the script currently bound to `pattern` is returned, or an empty string is returned if there is no binding for `pattern`. If neither `pattern` nor `script` is specified, then the return value is a list whose elements are all the patterns for which there exist bindings for `object`.

The `object` argument determines which window(s) the binding applies to. If `object` begins with a dot, as in `.a.b.c`, then it must be the path name for a window; otherwise it may be an arbitrary string. Like the regular `bind` command, bindings on window names are automatically removed if that window is destroyed. ๐Ÿซถ

### <purple>**`pathName notify configure object pattern ?option? ?value? ?option value ...?`**</purple>

This command sets and retrieves options for bindings created by the `notify bind` command.

If no `option` is specified, the command returns a list with option-value pairs describing all the available binding options for `pattern` on `object`. If `option` is specified with no `value`, then the command returns the current value of that option. If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s) for the binding; in this case the command 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. (It's the "do not disturb" toggle of bindings, lowkey. ๐Ÿ™ˆ)

### <purple>**`pathName notify detailnames eventName`**</purple>

Returns a list containing the names of all details, which are installed for the event with the name `eventName` by means of the `notify install` widget command or by the treectrl widget itself. ๐ŸŒธ

### <purple>**`pathName notify eventnames`**</purple>

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. โœจ

### <purple>**`pathName notify generate pattern ?charMap? ?percentsCommand?`**</purple>

This command causes the treectrl widget to generate an event. It's typically used to generate **dynamic** events created by the `notify install` command, but it may be used to generate static events also. 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 be `<eventName>`.

The optional `charMap` is a list of char-value pairs as in 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 will 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. See `notify install` for a description of `percentsCommand`. ๐Ÿ’œ

### <purple>**`pathName notify install pattern ?percentsCommand?`**</purple>

This command 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**. This command may be called 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. The command will be called to perform %-substitution on any scripts bound to the event specified by `pattern` (see **EVENTS AND SCRIPT SUBSTITUTIONS**). `PercentsCommand` should be defined as follows:

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. <red>If an error occurs evaluating `percentsCommand`, the %-character is replaced by itself.</red> ๐Ÿงš

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

### <purple>**`pathName notify install detail eventName detail ?percentsCommand?`**</purple>

<yellow>Deprecated.</yellow> Use `notify install` with a pattern of `<eventName-detail>` instead. (We don't do that anymore bestie, it's giving legacy code. ๐Ÿ’€)

### <purple>**`pathName notify install event eventName ?percentsCommand?`**</purple>

<yellow>Deprecated.</yellow> Use `notify install` with a pattern of `<eventName>` instead.

### <purple>**`pathName notify linkage pattern`**</purple>

Returns a string indicating whether the specified event or detail is created by means of the `notify install` widget command (**dynamic**) or by the treectrl widget itself (**static**). ๐Ÿ”ฅ

### <purple>**`pathName notify linkage eventName ?detail?`**</purple>

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

### <purple>**`pathName notify unbind object ?pattern?`**</purple>

If no `pattern` is specified, **all** bindings on `object` are removed. If `pattern` is specified, then the current binding for `pattern` is destroyed, leaving `pattern` unbound. Cleanup era, we love to see it. ๐ŸŽ€

---

### <purple>`pathName notify uninstall pattern`</purple> ๐Ÿฆ‹

If the event or detail named by *pattern* is **static** (aka the treectrl widget made it itself, it's not yours to touch bestie), you get an **error**. If it's dynamic though? Say bye ๐Ÿ’… the dynamic event or detail gets removed. And if you drop an event name with no detail attached, every single detail hanging off that event gets yeeted too.

### <purple>`pathName notify uninstall detail eventName detail`</purple>

> <red>Deprecated.</red> Use `notify uninstall` with a pattern of `<eventName-detail>` instead. (the glow-up is right there, use it ๐Ÿ™ˆ)

### <purple>`pathName notify uninstall event eventName`</purple>

> <red>Deprecated.</red> Use `notify uninstall` with a pattern of `<eventName>` instead.

---

### <cyan>`pathName numcolumns`</cyan> ๐ŸŒธ

> <red>Deprecated.</red> Use the `column count` command instead, bestie. Same energy, newer outfit โœจ

### <cyan>`pathName numitems`</cyan> ๐ŸŒธ

> <red>Deprecated.</red> Use the `item count` command instead.

### <cyan>`pathName orphans`</cyan> ๐Ÿงš

Returns a list of the item ids of every item that has **no parent**. When an item gets created it has no parent by default, and it can become an orphan later via the `item remove` widget command. Note: the root item is **not** included in this list. It's giving "who's your daddy" but nobody answers ๐Ÿ˜ญ

### <cyan>`pathName range first last`</cyan> ๐ŸŒˆ

> <red>Deprecated.</red> Use the `item range` command instead.

### <cyan>`pathName scan option args`</cyan> โญ

This one's how you implement scanning on treectrls. Two forms, depending on *option*:

#### <mint>`pathName scan mark x y`</mint>

Records *x* and *y* plus the treectrl's current view โ€” you use this with the later `scan dragto` commands. Typically you wire this up to a mouse button press in the widget, where *x* and *y* are the mouse coords. Returns an empty string.

#### <mint>`pathName scan dragto x y ?gain?`</mint>

This computes the difference between its *x* and *y* args (usually mouse coords, ofc) and the *x* and *y* args from the last `scan mark` command for the widget. Then it nudges the view by *gain* times that coordinate difference, and *gain* defaults to `10`. Usually hooked up to mouse motion events so it looks like you're yeeting the treectrl at high speed through its window. Return value is an empty string.

---

### <hotpink>`pathName see itemDesc ?columnDesc? ?option value ...?`</hotpink> ๐Ÿ‘‘

Adjusts the view so the item described by *itemDesc* is visible. If it's **already** visible, the command does literally nothing. Otherwise the treectrl scrolls to bring the item into view, and the matching `<Scroll-x>` and/or `<Scroll-y>` events fire. If you also pass *columnDesc*, then it's a specific column of the item that gets scrolled into view, not the whole entire item.

The following options are supported:

- **`-center`** *flags* โ€” *Flags* is a string holding zero or more of the characters `x` or `y`. This centers the item horizontally and/or vertically in the window. And it'll center it **regardless** of whether the item is already visible. main character energy fr fr ๐Ÿ’…

---

### <cyan>`pathName selection option args`</cyan> ๐ŸŽ€

This is how you mess with the selection inside a treectrl. Several forms, depending on *option*:

#### <lavender>`pathName selection add first ?last?`</lavender>

*first* and *last* (if given) must be valid item descriptions. If you pass **both** *first* and *last*, they may 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 items outside that range. If you only pass *first*, then every unselected item specified by *first* gets added. A `<Selection>` event fires if any items actually got added. ๐Ÿซถ

#### <lavender>`pathName selection anchor ?itemDesc?`</lavender>

If *itemDesc* is given, 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. The item description `anchor` can be used to refer to the anchor item. This command does **not** change the selection state of any item. Returns the unique id of the selection anchor item.

#### <lavender>`pathName selection clear ?first? ?last?`</lavender>

*first* and *last* (if specified) must be valid item descriptions. If you pass **both**, they may only refer to a **single item** โ€” then any selected items between *first* and *last* (inclusive) get removed from the selection, without affecting the selected state of items outside that range. If only *first* is given, every selected item specified by *first* is removed. If you pass **neither** *first* nor *last*, then **all** selected items get removed. A `<Selection>` event fires if any items actually got removed.

#### <lavender>`pathName selection count`</lavender>

Returns an integer = how many items in the treectrl are selected right now.

#### <lavender>`pathName selection get ?first? ?last?`</lavender>

With no extra args, the result is an **unsorted** list of the item ids of all currently-selected items. If nothing's selected, you get an empty string. The optional *first* and *last* args are treated as indices into the **sorted** list of selected items โ€” so you can do in-place `lindex` and `lrange` ops on the selection. Like, for example:

.t selection get 0 ; # return the first selected item .t selection get end ; # return the last selected item .t selection get 1 end-1 ; # return every selected item except the first and last


#### <lavender>`pathName selection includes itemDesc`</lavender>

Returns `1` if the item described by *itemDesc* is currently selected, `0` if it's not. Simple as โœจ

#### <lavender>`pathName selection modify select deselect`</lavender>

Both *select* and *deselect* are possibly-empty lists of item descriptions. Any unselected items in *select* get added to the selection, and any selected items in *deselect* get removed (except for those items that are **also** in *select*, they stay ๐Ÿ’…). A `<Selection>` event fires if any items were selected or deselected.

---

### <cyan>`pathName state option args`</cyan> ๐Ÿฆ‹

This manipulates the list of user-defined item states โ€” peep the **STATES** section below. Item states can also be handled with the `item state` command, and if you're doing states for header-rows, use the `header state` widget command instead. Exact behavior depends on the *option* arg that follows `state`. Supported forms:

#### <mint>`pathName state define stateName`</mint>

Defines a brand new state named *stateName*, which must **not** already be the name of an existing state. No duplicates bestie ๐Ÿ™ˆ

#### <mint>`pathName state linkage stateName`</mint>

Returns a string saying whether the specified state is user-defined via the `state define` widget command (**dynamic**) or predefined by the treectrl widget itself (**static**).

#### <mint>`pathName state names`</mint>

Returns a list with the names of all user-defined states.

#### <mint>`pathName state undefine ?stateName ...?`</mint>

Every *stateName* must be the name of a user-defined state. Removes this state from the list of user-defined states. poof, gone ๐Ÿ‘‹

---

### <hotpink>`pathName style option ?element? ?arg arg ...?`</hotpink> ๐Ÿ’–

This one manipulates styles โ€” think of a style as a geometry manager, but for elements. Exact behavior depends on the *option* arg that follows `style`. Supported forms:

#### <purple>`pathName style cget style option`</purple>

Returns the current value of the option named *option* associated with the style given by *style*. *option* may be any of the values accepted by the `style configure` widget command.

This command also accepts the `-statedomain` option. ๐Ÿ‘€

#### <purple>`pathName style configure style ?option? ?value? ?option value ...?`</purple>

Similar to the `configure` widget command, except it modifies options for the style given by *style* instead of options for the whole entire treectrl widget. If no *option* is given, the command returns a list describing all available options for *style* (see `Tk_ConfigureInfo` for the format of that list). If *option* is given with no *value*, you get a list describing just that one named option (it'll be identical to the corresponding sublist of the value you'd get with no *option* at all). And if you pass one or more *option*-*value* pairs, it modifies those option(s) to have those value(s) in *style*, and returns an empty string.

The following options are supported:

- **`-buttony`** *offset* โ€” Sets the distance from the top of the item that the expand/collapse button should be drawn at. If *offset* is an empty string (which is the **default**), the button gets centered vertically in the item. The value can be any of the forms acceptable to `Tk_GetPixels`. Heads up: this option only has an effect when the style is set in an item in the tree column. ๐ŸŒธ

- **`-orient varName`** โ€” tells the widget which way to lay out the elements chained to this style. It's gotta be either <mint>horizontal</mint> (that's the default, bestie ๐Ÿ’…) or <mint>vertical</mint>, or honestly any abbreviation of those two. Short and sweet.

---

## โœจ `pathName style create` โœจ

pathName style create name ?option value ...?


Okay so this one births a whole new style with the unique, user-defined name *name*. ๐ŸŽ€ After *name* you can drop any number of option-value pairs, and each pair sets one of the style's config options. Wanna know what options exist? Go peek at the `style configure` command, iykyk. The result you get back is the name of the shiny new style (yes, literally the same as the *name* option, no plot twist there).

Oh and this command ALSO takes the `-statedomain` option, with a value of either <mint>header</mint> or <mint>item</mint>, which says where this style is gonna be displayed. Slay.

## โœจ `pathName style delete` โœจ

pathName style delete ?style ...?


Deletes each of the named styles and hands you back an empty string. Bye bestie ๐Ÿ‘‹. Heads up though: if a style gets 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 no dangling drama.

## โœจ `pathName style elements` โœจ

pathName style elements style ?elementList?


This sets which elements should be laid out by this style. Every element in *elementList* has to be the name of an element that was created by the widget command `element create`. Duplicate names in *elementList*? Ignored, we don't do repeats. ๐Ÿšซ And any element that was named in a former call of this command for *style* but is NOT in *elementList* gets deleted from the elements laid out by *style*. Clean slate energy.

> Every element used by a style must have been created with the same value for the `-statedomain` option. No mixing, fr fr.

If you don't pass the *elementList* argument at all, you just get back a list containing the currently defined elements of *style*. Easy.

## โœจ `pathName style layout` โœจ

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


This one is basically the `configure` widget command's twin sister, except it modifies the options that *style* uses for laying out *element*, instead of messing with options for the whole entire treectrl widget. ๐ŸŒˆ

- No *option* given? You get a list of option-value pairs describing ALL the available options for the layout.
- *option* given with no value? You get back the value of that named option.
- One or more option-value pairs given? The command modifies the given option(s) to have the given value(s) for the layout, and returns an empty string.

The options of a layout have effect on exactly the one element *element* managed by *style*. Here's what's on the menu:

- **`-detach boolean`** โ€” says whether the element should be positioned all by itself, i.e. independent from the other elements. Default is <mint>false</mint>.
- **`-center flags`** โ€” *flags* is a string holding zero or more of the characters `x` or `y`. `x` makes the element center horizontally, `y` makes it center 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 get centered as a group. Now consider this, when there's another element chillin' to the right of `MyElement`:

.t style layout MyStyle MyElement -expand we .t style layout MyStyle MyElement -center x


  With the first call, `MyElement` gets centered only within the space that is NOT occupied by the other element, so `MyElement` will appear off-center, leaning left of the style. With the second call, `MyElement` gets centered within the style as long as it doesn't overlap the other element. The way that changes everything?? ๐Ÿ˜ญ

- **`-draw boolean`** โ€” this is a per-state option that decides 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 โ€” but bestie it STILL consumes space in the layout. Sneaky like that. ๐Ÿ’€
- **`-expand flags`** โ€” lets the external padding around the element grow when a style has more screen space than it needs. *flags* is a string with 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's allowed to increase. Typically used to justify an element. Default is an empty string.
- **`-iexpand flags`** โ€” lets the INTERNAL padding of the element and the display area of the element grow when a style has more screen space than it needs. *flags* is a string with 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's 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. Default is an empty string.
- **`-indent boolean`** โ€” for item styles, this says whether the element should be positioned to the right of the button/line area in the tree column. When <mint>false</mint>, the element is displayed beneath the buttons and lines in the tree column. This option is ignored unless `-detach` is true. For header styles, this says whether the element should be positioned to the right of the `-canvaspadx` padding. This option is ignored unless `-detach` is true or `-union` is specified. Default is <mint>true</mint>.
- **`-ipadx amount`** / **`-ipady amount`** โ€” *amount* says how much internal padding to leave on the left and right (that's `-ipadx`) or top and bottom (that's `-ipady`) sides of the element. *amount* can be a list of two values to specify padding for the two sides separately. Default value is `0`. Typically used with the `-union` layout option, to create space around the enclosed elements. ๐Ÿซถ
- **`-minheight pixels`** / **`-height pixels`** / **`-maxheight pixels`** โ€” specify the minimum, fixed, and maximum height of the display area of the element. Default is unspecified.
- **`-minwidth pixels`** / **`-width pixels`** / **`-maxwidth pixels`** โ€” specify the minimum, fixed, and maximum width of the display area of the element. Default is unspecified.
- **`-padx amount`** / **`-pady amount`** โ€” *amount* says how much EXTERNAL padding to leave on the left and right (`-padx`) or top and bottom (`-pady`) sides of the element. *amount* can be a list of two values to specify padding for the two sides separately. Default value is `0`.
- **`-squeeze flags`** โ€” lets the display area of an element shrink when a style has less space than it needs. *flags* is a string with zero or more of the characters `x` or `y`. `x` allows the display area to decrease horizontally, `y` allows it to decrease vertically. Typically used for text elements and it'll make the text element display an ellipsis (`...`) and/or wrap lines. Default is an empty string.
- **`-sticky flags`** โ€” controls how the actual display information (image, text, etc) of an element is positioned (or stretched) within its display area. *flags* is a string with 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 info should "stick" to. Default is `nswe`. โœจ

- <pink>**`-union`**</pink> *elementList* โ€” okay bestie, this one is giving "I contain multitudes" energy ๐Ÿ’…. It 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. No cap. โœจ

- <purple>**`-visible`**</purple> *boolean* โ€” this is a per-state option that controls visibility of an element. If the value of the option evaluates to false for a given item state, then the element is not displayed and consumes no space in the layout. ๐Ÿ™ˆ Lowkey a ghost. ๐Ÿ‘ป

---

### `pathName style names`

Returns a list containing the names of all existing styles. โœจ Slay.

---

### `pathName theme` *option* ?*arg ...*?

This command is used to interact with the platform-specific theme. The exact behavior of the command depends on the *option* argument that follows the `theme` argument. The following forms of the command are supported:

#### `pathName theme platform`

Returns the API used to draw themed parts of the treectrl. 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*

The command is available on MS Windows only. ๐ŸชŸ 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. ๐Ÿ’…

---

### `pathName toggle` ?`-recurse`? ?*itemDesc ...*?

Use `item toggle` instead. ๐Ÿšซ This one's deprecated, bestie โ€” don't come for me.

---

### `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`, 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. ๐ŸŒˆ

#### `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. ๐Ÿ’ƒ

---

### `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. ๐Ÿ’ซ

# โœจ HEADERS โœจ

Okay bestie, listen up ๐Ÿ’– a `treectrl` widget can show **zero or more** rows of column headers. When a `treectrl` widget gets created, one single row of column headers (aka a **header-row**) gets created right along with it โ€” and that top header-row is *forever*, you literally cannot delete it, it's the main character ๐Ÿ‘‘. Want more? Make them with `header create`. Want them gone? `header delete`. Simple as.

<purple>There are no commands for changing the order of header-rows.</purple> Nope. They just show up top-to-bottom in the order they were created. That's the vibe, that's the rule, periodt.

Drag-and-drop reordering of column headers is supported *within a widget* ๐Ÿฆ‹. To control column header drag-and-drop, use the `header dragconfigure` command. That's your girl for that.

Header-rows in a `treectrl` may be specified in a number of ways. See **HEADER DESCRIPTION** below ๐Ÿ‘‡

---

## ๐ŸŒธ Customizing individual column headers ๐ŸŒธ

The appearance of individual column headers within a header-row may 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. Do not mix those up bestie, I'm begging ๐Ÿ™ˆ

The following options are supported for each individual column header:

- **`-arrow direction`** โ€” Indicates whether or not a sort arrow should be drawn in the column header. *direction* must have one of the values `none` (the default), `up`, or `down`.
- **`-arrowbitmap bitmap`** โ€” Specifies as a per-state option the name of a bitmap to use to draw the arrow if this column's `-arrow` option is not `none`.
- **`-arrowgravity direction`** โ€” Indicates onto which side the sort arrow should be packed, if there is more space available for drawing the arrow then needed. *direction* must be either `left` (the default) or `right`.
- **`-arrowimage image`** โ€” Specifies as a per-state option 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`** โ€” *amount* specifies 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`** โ€” *amount* specifies 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`** โ€” Indicates 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`** โ€” Specifies the name of a bitmap to display to the left of the column title.
- **`-background color`** โ€” Specifies as a per-state option the color to use for the background of the column header.
- **`-borderwidth size`** โ€” Specifies 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 determines this). The value may have any of the forms acceptable to `Tk_GetPixels`.
- **`-button boolean`** โ€” Indicates 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`** โ€” Specifies 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`** โ€” Specifies the name of an image to display to the left of the column title. This option overrides the `-bitmap` column option.
- **`-imagepadx amount`** โ€” *amount* specifies 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`** โ€” *amount* specifies 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`** โ€” Specifies a text string to be displayed as the column title.
- **`-textcolor color`** โ€” Specifies as a per-state option 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`** โ€” Specifies 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`** โ€” *amount* specifies 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`** โ€” *amount* specifies 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 ๐ŸŽ€

So 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`** โ€” Specifies 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. She's always there, she never leaves ๐Ÿซถ

## ๐Ÿฆ‹ QUALIFIERS ๐Ÿฆ‹

- **`QUALIFIERS`** โ€” Specifies 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*. ๐Ÿ”ฅ

.t header dragconfigure {tag -funky} -draw yes


- **`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*.

---

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. Sneaky ๐Ÿ’€
- **`!visible`** โ€” When this qualifier is given, only header-rows that are ***not*** displayed are matched.

---

# โœจ COLUMNS โœจ

Okay bestie, this is where it gets *good*. A `treectrl` widget can show **multiple columns** side by side, like a little spreadsheet but cuter. And think of an **item** as a **row** โ€” one row that stretches all the way across every single column. ๐Ÿ‘‘

Columns in a `treectrl` can be set up in, like, a bunch of different ways. Scroll down to **COLUMN DESCRIPTION** for the deets.

There is *always* one special column, the **tail column**, and she fills up all the space to the right of the last ordinary column. She's the main character who eats up the leftovers ๐Ÿ“. This column has **no unique ID** โ€” the *only* way to point at her is with the keyword `tail`.

---

## ๐Ÿ’– Compatibility tea (iykyk)

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 โ€” can be passed to the **top header-row** through the `column configure` command, and queried with the `column cget` command. Old-school but she still works. โœจ

---

## ๐ŸŒธ The column options, one by one

- **`-expand`** *boolean* โ€” Says whether or not any extra horizontal space should get distributed to this column. Heads up: 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 all the way down into the whitespace region below any items. The default value for each option is an **empty string**, which means no lines get drawn at all. ๐Ÿ’…

- **`-itembackground`** *colorList* โ€” Takes a list of zero or more colors, used as **alternating background colors** for items in this column. Peep the `-backgroundmode` widget option for more on this. ๐ŸŒˆ

- **`-itemjustify`** *justification* โ€” Decides how the item styles in this column line up horizontally. Must be one of `left`, `center`, or `right`. The default value is an **empty string** (for compatibility with older versions), and in that case the column option `-justify` is what aligns 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 overridden 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 the value of this option **also** changes the `-justify` option of the column header in the **top header-row**. Two birds, one option. ๐Ÿฆ‹

- **`-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`. Lowkey essential for big tables. ๐Ÿ”ฅ

- **`-maxwidth`** *size* โ€” The maximum size, in screen units, permitted for this column. If *size* is an empty string, there's **no limit** on the max size of the column. This option does nothing if the `-width` option is set.

- **`-minwidth`** *size* โ€” The minimum size, in screen units, permitted for this column. If *size* is an empty string, the minimum size of the column is **zero**. This option does nothing if the `-width` option is set.

- **`-resize`** *boolean* โ€” A boolean value saying whether the user is allowed to resize the column by dragging the edge of the column's header. Default is `true`. Let them cook. ๐Ÿ‘‘

- **`-squeeze`** *boolean* โ€” A boolean value saying whether or not 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 does nothing 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 a non-empty value is supplied, this option puts the column into a **uniform group** with other columns that have the same value for `-uniform`. The space for columns in a uniform group is 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 or not the column should be displayed. ๐Ÿ‘€

- **`-weight`** *integer* โ€” Sets the relative weight for apportioning any extra space among columns. A weight of **zero** (`0`) means the column will not 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 allocated to columns. This option is based on the grid geometry manager. โญ

- **`-width`** *size* โ€” Specifies a **fixed width** for the column. If this value is an empty string, then the column width is calculated as the max 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 will **not** 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 an argument that describes **which column to operate on**. Wanna see it in action? The **EXAMPLES** section has examples. The initial part of a column description has to start with one of these terms:

- **`id`** โ€” Specifies 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*** โ€” Specifies a list of qualifiers. This gives the same result as `all` followed by *QUALIFIERS*; i.e., every column gets 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. Also โ€” you may run into trouble if *tagExpr* looks like a column id or other keyword; plus, *tagExpr* must look like a **single list element** since column descriptions are properly-formed lists. To be safe you may want to use the `tag` qualifier followed by *tagExpr*. ๐Ÿ™ˆ

- **`all`** *QUALIFIERS* โ€” Every column, including the **tail column** if the command allows it, which matches *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`. ๐ŸŒณ

---

## ๐ŸŽ€ Modifiers

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 these 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.

---

## ๐Ÿ’œ Qualifiers

The word *QUALIFIERS* up there means a sequence of **zero or more** of these terms, which changes which column gets 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**. ๐Ÿ™…โ€โ™€๏ธ

- **`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 every single column header AND every single item gets its own lil set of boolean states, right? and these states are <pink>lowkey the whole personality</pink> of how headers and items look โ€” the deets live down in PER-STATE OPTIONS. important tho: the states a <hotpink>header</hotpink> can have are a totally different set from the states an <hotpink>item</hotpink> can have. separate universes, bestie.

---

## ๐ŸŒธ HEADER STATES ๐ŸŒธ

these are the states every column header comes preloaded with:

- **`active`**
- **`normal`**
- **`pressed`** โ€” these three mirror whatever a column header's configuration option `-state` is set to. <cyan>exactly one</cyan> of them is on at any given moment in each column header. periodt.
- **`down`**
- **`up`** โ€” these two mirror the column header's `-arrow` option. if `-arrow` is `none`, then <yellow>neither</yellow> of them is set. rip.
- **`background`** โ€” gets set for every header-row when the toplevel window holding the treectrl is <purple>not</purple> the foreground active window. you cannot change this one with a widget command, nope โ€” it just maintains itself in reaction to the `<Activate>` and `<Deactivate>` windowing system events. she's autonomous ๐Ÿ’…
- **`focus`** โ€” set for every header-row when the treectrl widget has the focus. also not modifiable via widget command, also just vibing off the `<FocusIn>` and `<FocusOut>` windowing system events.

---

## ๐ŸŽ€ ITEM STATES ๐ŸŽ€

and these are the states every item gets born with:

- **`active`** โ€” at all times, exactly <cyan>one</cyan> item has this. the active item is the one keyboard navigation hangs out with. when the treectrl widget is created, or when the active item gets deleted, the <hotpink>root item</hotpink> becomes the active item. you can change this with the widget command `activate`.
- **`enabled`** โ€” set on every item the moment it's created. disabled items <red>cannot be selected</red> and the default bindings straight-up ignore them when you're keyboard-navigating. change it with the widget command `item enabled`.
- **`focus`** โ€” set on every item when the treectrl widget currently has focus. can't be changed with a widget command; it just reacts to `<FocusIn>` and `<FocusOut>` events.
- **`open`** โ€” when this is switched on, the item's descendants are displayed, aka the item is <green>expanded</green>. switched off? descendants are hidden, aka <red>collapsed</red>. new items have this switched on by default. modify it with `item expand`, `item collapse`, or `item toggle`.
- **`selected`** โ€” set on every item that's part of the selection. change it with the widget command `selection`.

---

and using the `state define` widget command, you can define up to <rainbow>27</rainbow> extra states on top of all that. slay.

---

# โœจ PER-STATE OPTIONS โœจ

okay this is the part where it gets cute. an item's whole visual look can <pink>change based on what state it's in</pink> โ€” like being the active item, being selected, being collapsed, or literally any combo of those or other states.

so when a configuration option is described as **per-state**, that means the option's value <purple>varies depending on the item's state</purple>. and here's the tea:

- if you give a per-state option just <cyan>one single value</cyan>, that value is used for <cyan>all</cyan> states. easy.
- otherwise, the per-state option has to be given as an <yellow>even-numbered list</yellow>.

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 could write:

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


so in that example, the `-font` option reads like `value stateList value stateList`. if a `stateList` is an <green>empty list</green>, the value before it is used regardless of the item's state. a <green>non-empty</green> `stateList` is a list of states that all have to be set on the item for the value before it to get used.

and get this โ€” each `stateList` can also include state names with a `!` in front of them, which means that state must <red>*not*</red> be set on the item. like:

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


in that one, the rect element is filled <blue>blue</blue> when the treectrl has focus and the item is selected. if the treectrl does <hotpink>not</hotpink> have focus, the example says gray should be used for selected items. and also note: if the item is not selected at all, then <yellow>no color is specified at all</yellow> for the `-fill` option. awkward but that's how it is ๐Ÿ™ˆ

---

each `value-stateList` pair gets checked <cyan>in order, left to right</cyan>. the value attached to the <pink>first</pink> `stateList` that matches the item's current state is the winner. so like, list your stateLists from <hotpink>most-specific to least-specific</hotpink>. queen shit.

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


written *this* way, gray will <red>always</red> be used for selected items because it shows up first, and blue will <red>never</red> be used for selected items no matter what the focus is doing. order matters bestie!!

and a value followed by an <green>empty stateList</green> should always go <hotpink>last</hotpink>, since it gets chosen regardless of the item's state. it's the catch-all, the safety net, the it-girl of defaults ๐Ÿ’…

---

# ๐Ÿงš ELEMENTS AND STYLES ๐Ÿงš

elements and styles are the <rainbow>core visual building blocks</rainbow> that determine how items look (and optionally, column headers too). an element can be one of these types: `bitmap`, `border`, `header`, `image`, `rect`, `text` or `window`.

you can assign one or more elements to a <purple>style</purple>, and the style handles the layout of those elements. ngl it really helps to think of an element as a Tk widget and a style as a Tk geometry manager like `grid`, `pack` or `place`. iykyk ๐Ÿซถ

so when an element gets created by the `element create` command, we call it a **master element**. same energy for styles โ€” a style created by `style create` is a **master style**. when a master style gets assigned to a column of an item via the `item style set` command, a brand new <cyan>instance style</cyan> is allocated, and it refers back to the master style and its master elements. this means one single master style can be shared by <pink>multiple columns of multiple items</pink>. and if you modify a master element or master style, those changes affect <hotpink>all</hotpink> the items whose instance styles and elements point back at those masters. efficient, iconic, no notes.

okay but here's the thing โ€” you probably want the font and selection-rectangle colors shared by <purple>all</purple> items, but you most likely do <red>not</red> want the text to be the same for every column of every item. so the `item element configure` command lets you override a master element's configuration options for a <cyan>specific column of a specific item</cyan>. when you call `item element configure` (or `item text` or `item image`), a new <green>instance element</green> gets allocated if one didn't already exist, and that instance element's options will override the master element's. ๐Ÿ’…

---

now listen: all of the element configuration options described below are <yellow>unspecified by default</yellow>, meaning like, no value <em>whatsoever</em> has been given to the option. and yeah i know it seems weird that a boolean option would be "unspecified" instead of just `true` or `false`. the reason is this: when an instance element used by an item has no value specified for an option, that instance element <pink>refers to the master element</pink> for the value. this is what lets items displaying a certain element get redisplayed when the master element's options change. the glow-up here is that you don't have to configure the font or text color for every single item in a treectrl individually โ€” which saves you <cyan>CPU cycles and memory</cyan>. no cap.

you might be thinking "to change the color of a selection rectangle i'd just call `item element configure` when an item gets selected, right?" โ€” and bestie, <red>that is not usually the case</red>. it would be straight up wasteful to allocate a new instance element for a selection rectangle just because an item became selected. the solution is to let the selection rectangle <purple>master element</purple> change its appearance based on the item's <hotpink>selected</hotpink> state. which is exactly what PER-STATE OPTIONS is about. we covered it, you're welcome ๐ŸŽ€

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

---

# ๐Ÿ–ผ๏ธ BITMAP ELEMENT ๐Ÿ–ผ๏ธ

an element of type `bitmap` is for displaying a bitmap in an item. these are the options it supports:

- **`-background`** *color* โ€” specifies, as a <purple>per-state</purple> option, the color to use for each of the bitmap's `'0'` valued pixels. if the value for a certain state is an <green>empty string</green> (which is the default), the bitmap is drawn <cyan>transparent</cyan>. see-through moment.
- **`-bitmap`** *bitmap* โ€” specifies, as a <purple>per-state</purple> option, the bitmap to display in the element.
- **`-draw`** *boolean* โ€” <red>deprecated</red>, use the style layout option `-draw` instead. specifies, as a <purple>per-state</purple> option, whether to draw the element. if the value for a certain state is an <green>empty string</green> (the default), it's treated as `true` and the element <green>will</green> be drawn.
- **`-foreground`** *color* โ€” specifies, as a <purple>per-state</purple> option, the color to use for each of the bitmap's `'1'` valued pixels. if the value for a certain state is an <green>empty string</green> (the default), the bitmap's foreground color is <yellow>black</yellow>.

---

# ๐ŸŽ€ BORDER ELEMENT ๐ŸŽ€

Okay bestie, if you want a lil 3D border situation inside an item, the <pink>border</pink> element type is literally right there. Here's everything it eats:

- **`-background color`** โ€” a <hotpink>per-state</hotpink> option, and it sets the color used for the background of the border. Real talk: if the value for a certain state is an empty string (that's the default), the element just... doesn't get drawn. Nothing. Nada. ๐Ÿ’€

- **`-draw boolean`** โ€” <red>deprecated, babes</red>, use the style layout option `-draw` instead. This is a per-state option that says 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 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, which means only the edges of the border get drawn. Outline only, main character energy. ๐Ÿ’…

- **`-height size`** โ€” the height of the border. If this value is unspecified (the default), the border is exactly as tall as its display area, as determined by the style layout options.

- **`-relief relief`** โ€” a per-state option for the relief of the border. If the value for a certain state is an empty string (the default), it's treated as flat. For the acceptable values, go peek at the description of the `-relief` option in the options manual page. ๐Ÿ‘€

- **`-thickness thickness`** โ€” the thickness of the edges of the border.

- **`-width size`** โ€” the width of the border. If this value is unspecified (the default), the border will be exactly as wide as its display area, as determined by the style layout options.

---

# ๐ŸŒˆ HEADER ELEMENT ๐ŸŒˆ

A <purple>header</purple> element type is for displaying a themed (or non-themed, we don't judge) column header background *and* a sort arrow. Pro move: header elements are best used surrounding other elements via the style layout option `-union`, so the sort arrow can actually be displayed correctly. ๐Ÿน

Some of the options for this element type get their default values from the header state flags set in the column header where the element is being displayed. Specifically: the `-arrow` option gets its default by checking the <cyan>up</cyan> and <cyan>down</cyan> state flags, and the `-state` option gets its default by checking the <cyan>active</cyan>, <cyan>normal</cyan>, and <cyan>pressed</cyan> state flags. If elements of this type show up in an *item* instead of a column header, then this behavior isn't used, because those state flags aren't meaningful for items. Sorry bestie, different context, different rules. ๐Ÿ™ˆ

Here's the full menu:

- **`-arrow direction`** โ€” indicates whether or not a sort arrow should be drawn. *Direction* has to be one of `none`, `up`, or `down`. If unspecified, the value defaults to `none` (but go reread the note above about header states, iykyk).

- **`-arrowbitmap bitmap`** โ€” a per-state option naming the bitmap to use to draw the sort arrow, when this element's `-arrow` option isn't `none`. Heads up: this option is ignored when drawing themed headers on Mac OS X. ๐ŸŽ

- **`-arrowgravity direction`** โ€” says which side the sort arrow gets packed onto, if there's more space available for drawing the arrow than needed. *Direction* must be either `left` or `right`. If unspecified, the value defaults to `left`. Also ignored when drawing themed headers on Mac OS X.

- **`-arrowimage image`** โ€” a per-state option naming the image to use to draw the sort arrow, when this element's `-arrow` option isn't `none`. If an image is specified for a certain state, it overrides the `-arrowbitmap` option. And yes โ€” ignored when drawing themed headers on Mac OS X.

- **`-arrowpadx amount`** โ€” *Amount* says how much padding to leave on the left and right of the sort arrow. It can be a list of two values to specify padding for the left and right separately. If unspecified, the value defaults to `6`. Padding to the right of the sort arrow is ignored when drawing themed headers on Mac OS X.

- **`-arrowpady amount`** โ€” *Amount* says how much padding to leave on the top and bottom of the sort arrow. It can be a list of two values to specify padding for the top and bottom separately. If unspecified, the value defaults to `0`. Ignored when drawing themed headers on Mac OS X.

- **`-arrowside side`** โ€” indicates which side of the element the sort arrow should be drawn on. *Side* must be either `left` or `right`. If unspecified, the value defaults to `right`.

- **`-background color`** โ€” a per-state option for the color to use for the non-themed background and 3D border. If unspecified, the value defaults to either the Tk button widget's `-background` or `-activebackground` color.

- **`-borderwidth size`** โ€” a non-negative value giving the width of the non-themed 3D border to draw around the inner edges of the element (if such a border is being drawn, that is โ€” the `-relief` option determines this). The value may take any of the forms acceptable to `Tk_GetPixels`. If unspecified, the value 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. The `pressed` state is used when the mouse button is pressed in the header. If unspecified, the value defaults to `normal` (but see that note above about header states, fr fr).

---

# ๐Ÿฆ‹ IMAGE ELEMENT ๐Ÿฆ‹

Want a pic in an item? The <mint>image</mint> element type does exactly that. Options below:

- **`-draw boolean`** โ€” <red>deprecated</red>, bestie, 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.

- **`-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 is no image.

- **`-image image`** โ€” a per-state option: the image to display in the element. ๐Ÿ–ผ๏ธ

- **`-tiled boolean`** โ€” a boolean saying whether the image should be tiled horizontally and vertically within the display area for the element. 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 is no image.

---

# ๐Ÿ’œ RECTANGLE ELEMENT ๐Ÿ’œ

Type <peach>rect</peach>, and yeah, it draws a rectangle in an item. The whole option list:

- **`-draw boolean`** โ€” <red>deprecated</red>, use the style layout option `-draw` instead. A per-state option for 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 gets drawn.

- **`-fill color`** โ€” a per-state option for the color used to fill the rectangle's area. If the color for a certain state is an empty string (the default), then the rectangle won't be filled (but the outline may still be drawn, so don't panic).

- **`-height size`** โ€” the height of the rectangle. If this value is unspecified (the default), the rectangle will be exactly as tall as its display area, as determined by the style layout options.

- **`-open open`** โ€” a per-state option for which edges of the rectangle should be left open. You'd use this to get an incomplete drawing of the outline and rounded corners, often to give the appearance that the rectangle extends over adjacent columns or items. ๐Ÿ‘€ *Open* is a string containing zero or more of the characters `n`, `s`, `e` or `w`. Each letter refers to an edge (north, south, east, or west) on which the outline and rounded corners will **not** be drawn. The default is the empty string, which causes all rounded corners and the outline to be drawn.

- **`-outline color`** โ€” a per-state option for the color used to draw the outline of the rectangle. If the color for a certain 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* may take 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 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 saying 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 this value is unspecified (the default), the rectangle will be exactly as wide as its display area, as determined by the style layout options.

# โœจ TEXT ELEMENT โœจ

okay so an element of type <pink>`text`</pink> is literally just there to display text in an item ๐Ÿ’–. Here's everything it vibes with:

- **`-draw`** *boolean* โ€” <yellow>Deprecated bestie, use the style layout option `-draw` instead</yellow> ๐Ÿ™ˆ. It's a per-state option saying whether to draw the element at all. If the value for a certain state is an empty string (that's the default), it gets treated as true and yeah, the element gets drawn ๐Ÿ’….
- **`-data`** *data* โ€” the value that, together with the `-datatype` and `-format` options, gets shown as text โœจ.
- **`-datatype`** *dataType* โ€” tells you what *kind* of info is chilling in `-data`. The acceptable values are `double`, `integer`, `long`, `string`, or `time` ๐ŸŒˆ.
- **`-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 gets displayed using the color from the treectrl's `-foreground` option.
  - In headers, if the color for a certain state is an empty string, then the text gets displayed using the system theme color on Gtk+ ๐Ÿ–ฅ๏ธ; and if that color isn't specified then the `-headerforeground` option is used instead.
- **`-font`** *font* โ€” per-state option for the font used when displaying text ๐Ÿ’œ. If the font for a certain state is an empty string, the text gets displayed using the font from the treectrl's `-font` option in items, or the `-headerfont` option in headers.
- **`-format`** *formatString* โ€” this one sets 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 the other `-datatype` values, *formatString* should be a valid format string for the Tcl `format` command. If you don't specify it, 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 on display ๐Ÿ“. *how* has to be one of `left`, `right`, or `center`. If this option is specified as an empty string (the default), `left` is used.
- **`-lines`** *lineCount* โ€” the maximum number of lines to display ๐Ÿ”ข. If more than *lineCount* lines would be displayed, the last line gets truncated with an ellipsis at the right ๐Ÿ˜ญ. If this option is specified as zero or an empty string (the default), there's no limit to how many lines get displayed, go off.
- **`-lmargin1`** *pixels* โ€” *pixels* is a screen distance that says 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 handles the indentation for the subsequent lines. If this option is specified as 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, iykyk ๐Ÿ’ซ.
- **`-lmargin2`** *pixels* โ€” *pixels* is a screen distance that says 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 specified as 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 too ๐Ÿ’ซ.
- **`-text`** *string* โ€” *string* is the string the element displays ๐Ÿ‘‘. *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 all ignored, no cap ๐Ÿ™….
- **`-textvariable`** *varName* โ€” the name of a variable ๐Ÿ“. The value of the variable is a string displayed by the element; and if the variable value changes then the element automatically updates itself to show the new value, main character energy fr fr โœจ. 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 just doesn't get 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* says how to handle lines in the text that are longer than the maximum line length ๐ŸŒ€. The 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 gets determined.

---

# ๐ŸชŸ WINDOW ELEMENT ๐ŸชŸ

an element of type <cyan>`window`</cyan> displays a Tk window inside an item, iconic behavior honestly ๐Ÿ’…. Here's what it supports:

- **`-clip`** *boolean* โ€” says whether the associated Tk window is a borderless frame that 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 that 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* โ€” says whether the associated Tk window should be destroyed when the element gets deleted ๐Ÿ’€. The element is 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* โ€” <yellow>Deprecated bestie, use the style layout option `-draw` instead</yellow> ๐Ÿ™ˆ. Per-state option for 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 gets 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 can't 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.

## ๐ŸŒŸ ITEM DESCRIPTION ๐ŸŒŸ

okay bestie, so <pink>so many</pink> of the treectrl commands want you to describe *which items* you're talking about. That description is a <hotpink>properly-formed Tcl list</hotpink> of keywords and arguments โ€” like, a real list, no messiness allowed. And the <cyan>very first word</cyan> of that list has to be one of these:

- **`id`** โ€” the unique item identifier, where *id* is whatever a previous `item create` widget command handed back to you, or `0` to mean the ever-present root item. Also go peek at the `-itemprefix` option. ๐Ÿ‘€
- **`QUALIFIERS`** โ€” a list of qualifiers. Does exactly the same thing as `all` followed by *QUALIFIERS*, i.e. every single item gets tested for a match. ๐Ÿซถ
- **`tagExpr QUALIFIERS`** โ€” *tagExpr* is a tag expression (run, don't walk, to **ITEM AND COLUMN TAGS**) and every item's tags get tested against it. Heads up: this keyword <red>cannot</red> be followed by any modifiers unless a single item is matched. And you can get yourself into trouble if *tagExpr* happens to look like an item id or some other keyword ๐Ÿ˜ญ โ€” also *tagExpr* has to look like a single list element, because item descriptions are properly-formed lists. Play it safe and use the `tag` qualifier followed by *tagExpr* instead.
- **`active`** โ€” the item that's currently active. Like, normally that's the item you passed to the last successful `activate` widget command, or the root item if that call never happened yet.
- **`anchor`** โ€” the anchor item of the selection, i.e. normally the item you passed to the last successful `selection anchor` widget command, or the root item if no such call ever happened.
- **`all QUALIFIERS`** โ€” every item including orphans, as long as it matches *QUALIFIERS*. This keyword <red>cannot</red> be followed by any modifiers unless a single item is matched.
- **`first QUALIFIERS`** โ€” the first item of the treectrl (that's the root item, queen ๐Ÿ‘‘), or the first item matching *QUALIFIERS*.
- **`end QUALIFIERS`** โ€” bestie this one gets the exact same description as `last` right below, so: Indicates the last item which matches *QUALIFIERS*.
- **`last QUALIFIERS`** โ€” the last item which matches *QUALIFIERS*.
- **`list itemDescs`** โ€” *itemDescs* is a list (and I mean **a single argument**, so like `list {a b c}` and *not* `list a b c` ๐Ÿ’…) of other item descriptions. This keyword <red>cannot</red> be followed by any modifiers unless a single item is matched.
- **`nearest x y`** โ€” the item nearest to the point given by *x* and *y*.
- **`rnc row column`** โ€” the item sitting in the given *row* and *column*. The row and column line up with the on-screen arrangement of items as decided by the `-orient` and `-wrap` options. Memorize `rnc` as "row 'n' column" ๐Ÿง โœจ
- **`range first last QUALIFIERS`** โ€” *first* and *last* specify a range of items. This keyword <red>cannot</red> be followed by any modifiers unless a single item is matched.
- **`root`** โ€” the root item of the treectrl.

---

The opening chunk of the item description (any of the values up above) can then be followed by <purple>one or more modifiers</purple>. A modifier shifts the item you're pointing at, relative to the description you've built so far. Here's every form it can take:

- **`above`** โ€” the item one row above, in this column.
- **`ancestors QUALIFIERS`** โ€” the ancestors of the item (basically like `item ancestors`, except *QUALIFIERS* can change which ancestors match). This keyword <red>cannot</red> be followed by any modifiers.
- **`below`** โ€” the item one row below, in this column.
- **`bottom`** โ€” the item in the last row of this column.
- **`child n QUALIFIERS`** โ€” the *n*th child of the item.
- **`children QUALIFIERS`** โ€” the children of the item (like `item children`, except *QUALIFIERS* can change which children match). This keyword <red>cannot</red> be followed by any modifiers.
- **`descendants QUALIFIERS`** โ€” the descendants of the item (like `item descendants`, except *QUALIFIERS* can change which descendants match). This keyword <red>cannot</red> be followed by any modifiers.
- **`firstchild QUALIFIERS`** โ€” the first child of the item.
- **`lastchild QUALIFIERS`** โ€” the last child of the item.
- **`left`** โ€” the item one column to the left, in the same row.
- **`leftmost`** โ€” the item in the first column, in the same row.
- **`next QUALIFIERS`** โ€” the next item, which is the first item from this list: the first child, the next sibling, or the next sibling of the nearest ancestor that has one. ๐Ÿ˜ฎโ€๐Ÿ’จ
- **`nextsibling QUALIFIERS`** โ€” the next sibling of the item.
- **`parent`** โ€” the parent of the item. ๐Ÿฅบ
- **`prev QUALIFIERS`** โ€” the last child of the previous sibling, or the parent if there is no previous sibling.
- **`prevsibling QUALIFIERS`** โ€” the previous sibling of the item.
- **`right`** โ€” the item one column to the right, in the same row.
- **`rightmost`** โ€” the item in the last column, in the same row.
- **`sibling n QUALIFIERS`** โ€” the *n*th child of the item's parent.
- **`top`** โ€” the item in the first row of this column.

---

That little word *QUALIFIERS* up there? It's a series of <green>zero or more</green> of these terms, and it changes which item gets 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) get considered.
- **`tag tagExpr`** โ€” *tagExpr* is a tag expression (see **ITEM AND COLUMN TAGS**) and an item's tags get tested against it for a match.
- **`visible`** โ€” when this qualifier is given, only items that are <mint>displayed</mint> get considered.
- **`!visible`** โ€” when this qualifier is given, only items that are <red>**not**</red> displayed get considered.

---

Wanna get the first item in the list that's enabled? Say less:

$T item id "first state enabled"


Wanna get the ancestors that aren't open, of the last item in the list? Here you go:

$T item id "last ancestors state !open"


Wanna get the visible descendants of the root item? ๐Ÿฆ‹

$T item id "root descendants visible"


Wanna get every hidden item with tag `"a"` or `"b"`? So many ways, all iconic:

$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 โœจ

So the *script* argument to `notify bind` is a Tcl script, and it gets evaluated every single time the given event is generated. That *script* runs in the same interpreter the `notify bind` command was executed in, and it runs at <hotpink>global level</hotpink> โ€” meaning only global variables are accessible, bestie, no locals for you ๐Ÿ™ˆ.

Now here's the fun part: if *script* contains any `%` characters, the script is <red>not</red> evaluated directly. Instead a **new** script gets generated, by replacing each `%` and the character right after it with info from the current event. And unlike the regular Tk `bind` mechanism, each event generated by a treectrl widget has its <purple>own</purple> set of %-substitutions. Periodt.

These %-substitutions are valid for <green>all</green> 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 gets replaced by

---

And here's the whole lineup of events a treectrl widget may generate ๐Ÿ’…

- **`<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 one is a whole vibe if you want to add child items to the item *just* before it expands ๐Ÿ‘‘
  - **`%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 item ids being deleted.

- **`<ItemVisibility>`** โ€” generated when items become visible on screen, and when items are no longer visible on screen. Genuinely so useful if you have a very large number of items and only want to assign styles when items are actually going to be displayed. โœจ
  - **`%h`** โ€” list of item ids which are no longer visible.
  - **`%v`** โ€” list of item 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 spills all the tea 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 ๐Ÿ’ซ

okay so bestie, you know the pre-defined *static* events like <ActiveItem> and <Selection>? yeah those are cute and all, but you can literally make your OWN events with the `notify install` command. custom event drop, we love to see it. ๐ŸŽ€

The library scripts ship an example of a dynamic event called `<Header-invoke>`, which gets generated when the mouse button is clicked and released over a column header. it's giving "click to sort" energy fr fr.

Example application code

treectrl .t .t notify install <Header-invoke> .t notify bind MyTag <Header-invoke> { 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 that example up there, a brand new treectrl widget gets created and the `<Header-invoke>` event gets installed. Then a script is bound to the event with `notify bind`, and it prints out the column ID, header ID and widget name to the console. In a *real* app, any script bound to `<Header-invoke>` would be used to sort the list based on the column header that got clicked. slay. ๐Ÿ’…

> heads up bestie: there is **no** *percentsCommand* argument to `notify install`. instead, the call to `notify generate` is what specifies the %-substitution command. the *charMap* argument to `notify generate` provides a list of %-substitution characters and values, which is used by `::TreeCtrl::PercentsCmd`. In the example, any `%C` in any script bound to the `<Header-invoke>` event gets replaced by the value of `$Priv(column)`, and `%H` gets replaced by `$Priv(header)`. The library procedure `::TreeCtrl::PercentsCmd` also supports the same common %-substitution characters as the built-in static events, like `%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. the vibes are pre-loaded, 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. it's giving glow-up. โœจ 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, and bestie you need to know them:

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. ๐Ÿซถ

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 bestie so here's the tea on how gradient brushes figure out their size ๐Ÿ’…

By default, a gradient brush is *exactly* the same size as whatever rectangle is being painted. So like, if a column's `-itembackground` option specifies a gradient name, then the background of an item gets painted with **all** the colors of the gradient. Which means a vertical gradient from blue to green will start blue at the top and end green at the bottom of *every single item*. no cap. ๐Ÿฆ‹

But wait, there's more โ€” 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. iconic behavior honestly โœจ

> lowkey important: 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. it's giving "why are you doing that" ๐Ÿ˜ญ

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 ๐Ÿ‘€

`bind(3tk)`, `bitmap(3tk)`, `image(3tk)`, `listbox(3tk)`, `options(3tk)`

---

# ๐Ÿ”‘ KEYWORDS ๐Ÿ”‘

tree, widget

---

and that's a wrap on the whole treectrl(3tk) saga, bestie!! ๐ŸŽ€ this page is from **treectrl 2.4.1** and it's literally the `treectrl(3tk)` manual โ€” you made it to the end, so proud of you ๐Ÿซถ go forth and build the most iconic tree widget the world has ever seen. periodt ๐Ÿ’–๐ŸŒˆโœจ