The tablelist::tablelist
Command
For Tablelist Version 5.13
by
Csaba Nemethi
csaba.nemethi@t-online.deContents
Quick Reference
- NAME
tablelist::tablelist
– Create and manipulate tablelist widgets- SYNOPSIS
-
tablelist::tablelist pathName ?options?
- STANDARD OPTIONS
-
-borderwidth -highlightthickness -setgrid -cursor -relief -xscrollcommand -exportselection -selectbackground -yscrollcommand -highlightbackground -selectborderwidth -highlightcolor -selectforeground
- OPTIONS FOR THE BODY COMPONENT OF THE WIDGET
-
-background -disabledforeground -font -foreground
- WIDGET-SPECIFIC OPTIONS
-acceptchildcommand command
-acceptdropcommand command
-activestyle frame|none|underline
-arrowcolor color
-arrowdisabledcolor color
-arrowstyle flat5x3|flat5x4|flat6x4|flat7x4|flat7x5| flat7x7|flat8x5|flat9x5|flat9x6|
flatAngle7x4| flatAngle7x5|flatAngle9x5|flatAngle9x6|flat1Angle9x7|
flatAngle10x6| flatAngle10x7|photo7x7|sunken8x7|sunken10x9| sunken12x11-autoscan boolean
-collapsecommand command
-columns {width title ?left|right|center? width title ?left|right|center? ...}
-columntitles {title title ...}
-customdragsource boolean
-editendcommand command
-editselectedonly boolean
-editstartcommand command
-expandcommand command
-forceeditendcommand boolean
-fullseparators boolean
-height lines
-incrarrowtype up|down
-instanttoggle boolean
-labelactivebackground color
-labelactiveforeground color
-labelbackground color
or-labelbg color
-labelborderwidth screenDistance
or-labelbd screenDistance
-labelcommand command
-labelcommand2 command
-labeldisabledforeground color
-labelfont font
-labelforeground color
or-labelfg color
-labelheight lines
-labelpady screenDistance
-labelrelief raised|sunken|flat|ridge|solid| groove
-listvariable variable
-movablecolumns boolean
-movablerows boolean
-movecolumncursor cursor
-movecursor cursor
-populatecommand command
-protecttitlecolumns boolean
-resizablecolumns boolean
-resizecursor cursor
-selectmode single|browse|multiple|extended
-selecttype row|cell
-setfocus boolean
-showarrow boolean
-showeditcursor boolean
-showhorizseparator boolean
-showlabels boolean
-showseparators boolean
-snipstring string
-sortcommand command
-spacing screenDistance
-state normal|disabled
-stretch all|columnIndexList
-stripebackground color
or-stripebg color
-stripeforeground color
or-stripefg color
-stripeheight lines
-takefocus 0|1|""|command
-targetcolor color
-tight boolean
-titlecolumns number
-tooltipaddcommand command
-tooltipdelcommand command
-treecolumn columnIndex
-treestyle adwaita|ambiance|aqua|baghira|dust| dustSand|gtk|
klearlooks| mate|mint|newWave|oxygen1|oxygen2|
phase| plastik|plastique|radiance|ubuntu|
vistaAero| vistaClassic|win7Aero|win7Classic|
winnative| winxpBlue|winxpOlive|winxpSilver-width characters
- COLUMN CONFIGURATION OPTIONS
-align left|right|center
-background color
or-bg color
-changesnipside boolean
-changetitlesnipside boolean
-editable boolean
-editwindow name
-font font
-foreground color
or-fg color
-formatcommand command
-hide boolean
-labelalign left|right|center
-labelbackground color
or-labelbg color
-labelborderwidth screenDistance
or-labelbd screenDistance
-labelcommand command
-labelcommand2 command
-labelfont font
-labelforeground color
or-labelfg color
-labelheight lines
-labelimage image
-labelpady screenDistance
-labelrelief raised|sunken|flat|ridge|solid| groove
-maxwidth width
-name name
-resizable boolean
-selectbackground color
-selectforeground color
-showarrow boolean
-showlinenumbers boolean
-sortcommand command
-sortmode ascii|asciinocase|command|dictionary| integer|real
-stretchable boolean
-stripebackground color
-stripeforeground color
-text list
-title title
-valign center|top|bottom
-width width
-wrap boolean
- ROW CONFIGURATION OPTIONS
-background color
or-bg color
-font font
-foreground color
or-fg color
-hide boolean
-name name
-selectable boolean
-selectbackground color
-selectforeground color
-text list
- CELL CONFIGURATION OPTIONS
-background color
or-bg color
-editable boolean
-editwindow name
-font font
-foreground color
or-fg color
-image image
-selectbackground color
-selectforeground color
-stretchwindow boolean
-text text
-valign center|top|bottom
-window command
-windowdestroy command
-windowupdate command
- DESCRIPTION
- COLORS AND FONTS
- USING A TABLELIST AS MULTI-COLUMN TREE WIDGET
- INTERACTIVE CELL EDITING
- DRAG & DROP SUPPORT
- VIRTUAL EVENTS
- ROW INDICES
-
number knumber active anchor end last top bottom @x,y name
- NODE INDICES
-
root number knumber active anchor end last top bottom @x,y name
- COLUMN INDICES
-
number active anchor end last left right @x,y name
- CELL INDICES
-
row,col active anchor end last @x,y row: number knumber active anchor end last top bottom name col: number active anchor end last left right name
- WIDGET COMMAND
pathName activate index
pathName activatecell cellIndex
pathName applysorting itemList
pathName attrib ?name? ?value name value ...?
pathName bbox index
pathName bodypath
pathName bodytag
pathName canceledediting
pathName cancelediting
pathName cellattrib cellIndex ?name? ?value name value ...?
pathName cellbbox cellIndex
pathName cellcget cellIndex option
pathName cellconfigure cellIndex ?option? ?value option value ...?
pathName cellindex cellIndex
pathName cellselection option args
pathName cellselection anchor cellIndex
pathName cellselection clear firstCell lastCell
pathName cellselection clear cellIndexList
pathName cellselection includes cellIndex
pathName cellselection set firstCell lastCell
pathName cellselection set cellIndexList
pathName cget option
pathName childcount nodeIndex
pathName childindex index
pathName childkeys nodeIndex
pathName collapse index ?-fully|-partly?
pathName collapseall ?-fully|-partly?
pathName columnattrib columnIndex ?name? ?value name value ...?
pathName columncget columnIndex option
pathName columnconfigure columnIndex ?option? ?value option value ...?
pathName columncount
pathName columnindex columnIndex
pathName columnwidth columnIndex ?-requested|-stretched|-total?
pathName configcelllist {cellIndex option value cellIndex option value ...}
pathName configcells ?cellIndex option value cellIndex option value ...?
pathName configcolumnlist {columnIndex option value columnIndex option value ...}
pathName configcolumns ?columnIndex option value columnIndex option value ...?
pathName configrowlist {index option value index option value ...}
pathName configrows ?index option value index option value ...?
pathName configure ?option? ?value option value ...?
pathName containing y
pathName containingcell x y
pathName containingcolumn x
pathName cornerlabelpath
pathName cornerpath
pathName curcellselection
pathName curselection
pathName delete first last
pathName delete indexList
pathName deletecolumns firstColumn lastColumn
pathName deletecolumns columnIndexList
pathName depth nodeIndex
pathName descendantcount nodeIndex
pathName editcell cellIndex
pathName editinfo
pathName editwinpath
pathName editwintag
pathName entrypath
pathName expand index ?-fully|-partly?
pathName expandall ?-fully|-partly?
pathName expandedkeys
pathName fillcolumn columnIndex text
pathName findcolumnname name
pathName findrowname name ?-descend? ?-parent nodeIndex?
pathName finishediting
pathName formatinfo
pathName get first last
pathName get indexList
pathName getcells firstCell lastCell
pathName getcells cellIndexList
pathName getcolumns firstColumn lastColumn
pathName getcolumns columnIndexList
pathName getformatted first last
pathName getformatted indexList
pathName getformattedcells firstCell lastCell
pathName getformattedcells cellIndexList
pathName getformattedcolumns firstColumn lastColumn
pathName getformattedcolumns columnIndexList
pathName getfullkeys first last
pathName getfullkeys indexList
pathName getkeys first last
pathName getkeys indexList
pathName hasattrib name
pathName hascellattrib cellIndex name
pathName hascolumnattrib columnIndex name
pathName hasrowattrib index name
pathName hidetargetmark
pathName imagelabelpath cellIndex
pathName index index
pathName insert index ?item item ...?
pathName insertchildlist parentNodeIndex childIndex itemList
pathName insertchild(ren) parentNodeIndex childIndex ?item item ...?
pathName insertcolumnlist columnIndex {width title ?left|right|center? width title ?left|right|center? ...}
pathName insertcolumns columnIndex ?width title ?left|right|center? width title ?left|right|center? ...?
pathName insertlist index itemList
pathName iselemsnipped cellIndex fullTextName
pathName isexpanded index
pathName istitlesnipped columnIndex fullTextName
pathName isviewable index
pathName itemlistvar
pathName labelpath columnIndex
pathName labels
pathName labeltag
pathName move sourceIndex targetIndex
pathName move sourceIndex targetParentNodeIndex targetChildIndex
pathName movecolumn sourceColumn targetColumn
pathName nearest y
pathName nearestcell x y
pathName nearestcolumn x
pathName noderow parentNodeIndex childIndex
pathName parentkey nodeIndex
pathName refreshsorting ?parentNodeIndex?
pathName rejectinput
pathName resetsortinfo
pathName rowattrib index ?name? ?value name value ...?
pathName rowcget index option
pathName rowconfigure index ?option? ?value option value ...?
pathName scan mark|dragto x y
pathName searchcolumn columnIndex pattern ?options?
pathName see index
pathName seecell cellIndex
pathName seecolumn columnIndex
pathName selection option args
pathName selection anchor index
pathName selection clear first last
pathName selection clear indexList
pathName selection includes index
pathName selection set first last
pathName selection set indexList
pathName separatorpath ?columnIndex?
pathName separators
pathName showtargetmark before|inside index
pathName size
pathName sort ?-increasing|-decreasing?
pathName sortbycolumn columnIndex ?-increasing|-decreasing?
pathName sortbycolumnlist columnIndexList ?sortOrderList?
pathName sortcolumn
pathName sortcolumnlist
pathName sortorder
pathName sortorderlist
pathName targetmarkpath
pathName targetmarkpos y ?-any|-horizontal|-vertical?
pathName togglecolumnhide firstColumn lastColumn
pathName togglecolumnhide columnIndexList
pathName togglerowhide first last
pathName togglerowhide indexList
pathName toplevelkey index
pathName unsetattrib name
pathName unsetcellattrib cellIndex name
pathName unsetcolumnattrib columnIndex name
pathName unsetrowattrib index name
pathName viewablerowcount ?first last?
pathName windowpath cellIndex
pathName xview args
pathName xview
pathName xview units
pathName xview moveto fraction
pathName xview scroll number units|pages
pathName yview args
pathName yview
pathName yview units
pathName yview moveto fraction
pathName yview scroll number units|pages
- DEFAULT AND INDIVIDUAL BINDINGS FOR THE TABLELIST BODY
- DEFAULT AND INDIVIDUAL BINDINGS FOR THE HEADER LABELS
- DEFAULT BINDINGS FOR INTERACTIVE CELL EDITING
- KEYWORDS
- tablelist, multi-column, listbox, tree, widget
Detailed Reference
- NAME
tablelist::tablelist
– Create and manipulate tablelist widgets- SYNOPSIS
-
tablelist::tablelist pathName ?options?
- STANDARD OPTIONS
-
-borderwidth -highlightthickness -setgrid -cursor -relief -xscrollcommand -exportselection -selectbackground -yscrollcommand -highlightbackground -selectborderwidth -highlightcolor -selectforeground
- See the options manual entry for details on the standard
options. The
-highlightbackground
,-highlightcolor
, and-highlightthickness
options are only supported by the Tablelist package, but not by Tablelist_tile. When using the package Tablelist_tile, the options-selectbackground
,-selectborderwidth
, and-selectforeground
have theme-specific default values. - OPTIONS FOR THE BODY COMPONENT OF THE WIDGET
-
-background -disabledforeground -font -foreground
- These options (described in the options manual entry) are only valid for the body component of the tablelist widget. As discussed in the next section, the colors and font used when drawing the header labels can be different from those specified for the body. When using the package Tablelist_tile, these options have theme-specific default values.
- WIDGET-SPECIFIC OPTIONS
-
Command-Line Name: -acceptchildcommand
Database Name: acceptChildCommand
Database Class: AcceptChildCommand
Specifies a Tcl command used to decide whether a given tablelist node may accept a specified item being moved interactively as a child. The specified command is automatically concatenated with the name of the tablelist widget, the node index of the would-be new parent node, and the row index of the dragged item, the resulting script is evaluated in the global scope, and the return value (which must be a boolean) will determine whether to allow to move the source item to the current mouse position as a child of the given parent node.
For example, in the case of a tablelist widget used as a file manager, in which the top-level items represent volumes mounted on the system, the command specified by this option might look like in the (pseudo-)code below:
proc acceptChildCmd {tbl targetParentNodeIdx sourceRow} { if {[string compare $targetParentNodeIdx "root"] == 0} { # Allow only volumes as top-level items return [expr {[$tbl depth $sourceRow] == 1}] } else { # Allow only directories as parent items return [$targetParentNodeIdx represents a directory] } }
For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this option is not supported for Tk versions earlier than 8.3. -
Command-Line Name: -acceptdropcommand
Database Name: acceptDropCommand
Database Class: AcceptDropCommand
Specifies a Tcl command used to decide whether a given tablelist row may accept a specified item being moved interactively to be dropped as a sibling just before that row. The specified command is automatically concatenated with the name of the tablelist widget, the row index of the would-be new target, and the row index of the dragged item, the resulting script is evaluated in the global scope, and the return value (which must be a boolean) will determine whether to allow to move the source item to the current mouse position, just before the given row.
For example, to make sure that the position of the last row of a tablelist widget won't be affected by the interactive row move operation, the command specified by this option might look like in the code below:
proc acceptDropCmd {tbl targetRow sourceRow} { set rowCount [[$tbl size] return [expr {$sourceRow != $rowCount - 1 && $targetRow < $rowCount}] }
-
Command-Line Name: -activestyle
Database Name: activeStyle
Database Class: ActiveStyle
Specifies how to diplay the active item or element (depending on the value of the
-selecttype
configuration option) when the tablelist has the keyboard focus. The allowed values areframe
,none
, andunderline
. The default valueframe
shows a thin frame around the active item or element, which in most cases looks nice. It looks less pretty when applied to the active item if the background color of some of its cells was changed by using thecolumnconfigure
orcellconfigure
widget command and no column separators are shown. The valuenone
specifies that no special indication of the active item or element is to be performed. The valueunderline
produces the same visual effect as in the case of the Tk core listbox. -
Command-Line Name: -arrowcolor
Database Name: arrowColor
Database Class: ArrowColor
Specifies the color to use for the up- or down-arrow placed into a column label by the
sortbycolumn
orsortbycolumnlist
subcommand of the Tcl command associated with the widget. This option is only relevant if the value of the-showarrow
option is true. The default value depends on the windowing system in the Tablelist package and on the current theme in Tablelist_tile. For example, if the windowing system isx11
then the default is an empty string, indicating that the arrow will inherit the background color of the label in which it is placed (but is distinguishable from the latter, due to its 3-D border and sunken relief, because in this case the-arrowstyle
option has the default valuesunken10x9
). On the windowing systemwin32
, the default arrow color is#aca899
for Windows XP,#569bc0
for Windows Vista and Windows 7, and an empty string for older Windows versions, paired with the default arrow styleflat9x5
,flat7x4
, andsunken8x7
, respectively. Finally, for the windowing systemsclassic
andaqua
on the Macintosh, the default arrow color and style depend on the version of the operating system: Starting with version 10.10 (Yosemite) of Mac OS X, the default arrow color for the windowing systemaqua
is#404040
and the default arrow style isflatAngle7x4
. For earlier operating system versions, the default values are the arrow color#717171
and the arrow styleflat7x7
(orphoto7x7
, in the presence of PNG support). -
Command-Line Name: -arrowdisabledcolor
Database Name: arrowDisabledColor
Database Class: ArrowDisabledColor
Specifies the color to use for the up- or down-arrow placed into a column label by the
sortbycolumn
orsortbycolumnlist
subcommand of the Tcl command associated with the widget when the tablelist'sstate
isdisabled
. This option is only relevant if the value of the-showarrow
option is true. When the default value of the-arrowcolor
option is an empty string then this is the default for the-arrowdisabledcolor
option, too; otherwise the latter's default value equals the default foreground color of the header labels indisabled
state. -
Command-Line Name: -arrowstyle
Database Name: arrowStyle
Database Class: ArrowStyle
Specifies the relief, shape, width, and height of the up- or down-arrow placed into a column label by the
sortbycolumn
orsortbycolumnlist
subcommand of the Tcl command associated with the widget. This option is only relevant if the value of the-showarrow
option is true. The currently supported values areflat5x3
,flat5x4
,flat6x4
,flat7x4
,flat7x5
,flat7x7
,flat8x5
,flat9x5
,flat9x6
,flatAngle7x4
,flatAngle7x5
,flatAngle9x5
,flatAngle9x6
,flatAngle9x7
,flatAngle10x6
,flatAngle10x7
,photo7x7
,sunken8x7
,sunken10x9
, andsunken12x11
, as shown in the picture below. The default value depends on the windowing system in the Tablelist package and on the current theme in Tablelist_tile; see the description of the-arrowcolor
option for details.While the sort arrows of the styles
flat*
andsunken*
are created from bitmaps, the arrow stylephoto7x7
uses PNG images that look and behave very close to the native sort arrows on Mac OS X Aqua versions earlier than 10.10 (Yosemite). This arrow style is only supported if the Tk version is either 8.6 (with built-in PNG support), or 8.5 and theimg::png
package can be loaded into the interpreter. When supported,photo7x7
will be the default value of the-arrowstyle
option in Tablelist_tile with theaqua
theme for Mac OS X versions earlier than 10.10 (otherwiseflat7x7
will be used as default for these earlier OS X versions). When using this arrow style, the-arrowcolor
and-arrowdisabledcolor
options have no effect, but, due to the transparency information contained in the PNG images, the arrows will automatically adapt their color to the various states of the header labels, just like the native sort arrows. -
Command-Line Name: -autoscan
Database Name: autoScan
Database Class: AutoScan
Specifies a boolean value that controls whether to trigger the automatic scrolling when the mouse leaves the tablelist window with button 1 down. The default is
1
, meaning that automatic scrolling will be in effect, just like in the case of the Tk listbox widget. However, when using the TkDND package or some other drag & drop implementation, you might want to set this option to0
, in order to avoid any conflicts between the drag operation and the automatic scrolling.REMARK: Starting with Tablelist version 5.12, this option has become obsolete, because the default bindings now suppress the above-mentioned automatic scrolling if the tablelist's body component was registered as a drag source for mouse button 1 via the
tkdnd::drag_source register
or the BWidgetDragSite::register
command, or the tablelist's-customdragsource
option was set to true. -
Command-Line Name: -collapsecommand
Database Name: collapseCommand
Database Class: CollapseCommand
Specifies a Tcl command to be invoked when collapsing a row of a tablelist used as a tree widget (with the aid of the
collapse
orcollapseall
subcommand). The specified command is automatically concatenated with the name of the tablelist widget and the row index, and the resulting script is evaluated in the global scope, before hiding the descendants of the row in question.For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this option is not supported for Tk versions earlier than 8.3. -
Command-Line Name: -columns
Database Name: columns
Database Class: Columns
Specifies the widths, titles, and alignments of the columns. The option's value must be a list of the form
width title ?alignment? width title ?alignment? ...
Each
width
must be a number. A positive value specifies the column's width in average-size characters of the widget's font. Ifwidth
is negative, its absolute value is interpreted as a column width in pixels. Finally, a value of zero specifies that the column's width is to be made just large enough to hold all the elements in the column, including its header (but no larger than the maximum width indicated by the-maxwidth
column configuration option). In all three cases, the effective column width will be somewhat greater because of the margins created automatically to the left and right of the column.Each
title
specifies the text to be displayed in the column's header, and may optionally be followed in the next list element by analignment
, which specifies how to align the elements of the column. Eachalignment
must be one ofleft
,right
, orcenter
. The default isleft
. Thealignment
also refers to the column's title as long as the-labelalign
option hasn't been specified for that column, or if its value is an empty string.The default value of this option is an empty list, specifying that initially the widget has no columns.
REMARK: Columns whose width was specified as zero are called dynamic-width columns. In general, they are more user-friendly than their static-width counterparts, being that their widths are automatically adapted to their contents. On the other hand, the static-width columns perform significantly better on item insertion and sorting than the dynamic-width ones, due to some optimizations introduced in Tablelist version 5.6. (Prior to that release, the above-mentioned operations were faster with dynamic-width columns than with static-width ones.)
-
Command-Line Name: -columntitles
Database Name: columnTitles
Database Class: ColumnTitles
This option provides a simplified form of specifying dynamic-width, left-aligned tablelist columns. Its value is viewed as a list of column titles. The default is an empty list.
In the simplest case that no columns have been specified yet, setting this option to the value given by the list
title title ...
is equivalent to setting the
-columns
option to the value given by the list0 title left 0 title left ...
If the columns have already been specified then this option updates their titles (as many of them as possible) and, if the number of elements of its value is greater than the number of columns then it uses the remaining elements as titles of additional dynamic-width, left-aligned columns. For example, if the widget has 3 columns and the option's value is a list of length 5 then the option will update the titles of the 3 columns and will append 2 new dynamic-width, left-aligned columns having as titles the last 2 elements of the list. If the widget has 3 columns and the option specifies just 2 texts then it will update the titles of the first 2 columns only.
-
Command-Line Name: -customdragsource
Database Name: customDragSource
Database Class: CustomDragSource
Specifies a boolean value that indicates whether the tablelist widget is a drag source for some drag & drop implementation other than TkDND and the drag & drop framework included in BWidget. If true then the default bindings will perform an automatic drag-friendly handling of the selection and will suppress the automatic scrolling when the mouse leaves the tablelist window with button 1 down. The default is
0
. -
Command-Line Name: -editendcommand
Database Name: editEndCommand
Database Class: EditEndCommand
Specifies a Tcl command to be invoked on normal termination of the interactive editing of a cell's contents if the final text of the temporary embedded widget used for the editing is different from its initial one. The command is automatically concatenated with the name of the tablelist widget, the cell's row and column indices, as well as the final contents of the edit window, the resulting script is evaluated in the global scope, and the return value becomes the cell's new contents after destroying the temporary embedded widget. The main purpose of this script is to perform a final validation of the edit window's contents. See the description of the
-forceeditendcommand
option for more about the invocation of the command mentioned above, as well as the INTERACTIVE CELL EDITING section for details on the editing process. -
Command-Line Name: -editselectedonly
Database Name: editSelectedOnly
Database Class: EditSelectedOnly
Specifies a boolean value that controls whether to start the interactive cell editing when mouse button 1 is pressed in an editable cell. If this value is true then the editing will only be started if the cell has previously been selected (interactively or programmatically). In this case, a first left-click will usually just select the cell (or its row, depending on the value of the
-selecttype
option), and a second mouse click will start the editing session. The default is0
, meaning that the editing will be started regardless of whether the cell is selected or not. -
Command-Line Name: -editstartcommand
Database Name: editStartCommand
Database Class: EditStartCommand
Specifies a Tcl command to be invoked when the interactive editing of a cell's contents is started. The command is automatically concatenated with the name of the tablelist widget, the cell's row and column indices, as well as the text displayed in the cell, the resulting script is evaluated in the global scope, and the return value becomes the initial contents of the temporary embedded widget used for the editing. The main purpose of this script is to define validations for the edit window's contents. See the INTERACTIVE CELL EDITING section for details on the editing process.
-
Command-Line Name: -expandcommand
Database Name: expandCommand
Database Class: ExpandCommand
Specifies a Tcl command to be invoked when expanding a row of a tablelist used as a tree widget (with the aid of the
expand
orexpandall
subcommand). The specified command is automatically concatenated with the name of the tablelist widget and the row index, and the resulting script is evaluated in the global scope, before displaying the children of the row in question.For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this option is not supported for Tk versions earlier than 8.3.REMARK: It is common practice to use the command specified as the value of this option to insert the children of the row that is about to be expanded, if it has no children yet. For example, the Directory Viewer demo script uses the command implemented as follows:
proc expandCmd {tbl row} { if {[$tbl childcount $row] == 0} { # Get the name of the directory whose leaf name is # displayed in the first cell of the specified row set dir [$tbl rowattrib $row pathName] # Display the contents of the directory $dir # as child items of the one identified by $row putContents $dir $tbl $row } # The rest is just eye candy: if {[$tbl childcount $row] != 0} { # Update the image displayed in the row's first cell $tbl cellconfigure $row,0 -image openFolderImg } }
-
Command-Line Name: -forceeditendcommand
Database Name: forceEditEndCommand
Database Class: ForceEditEndCommand
Specifies a boolean value that controls the invocation of the command given by the the
-editendcommand
option. If this value is true then the command will be invoked on normal termination of the editing process even if the final text of the temporary embedded widget used for the editing equals its initial one, and will also be invoked when the interactive cell editing is canceled (in the latter case, the text passed to it as last argument will be the cell's original contents, not its final one). The default value of this option is0
, meaning that the command will only be invoked on normal termination of the editing process, if the final text of the temporary embedded widget is different from its initial one. See the INTERACTIVE CELL EDITING section for details on the editing process.If the option's value is true and no value for the
-editendcommand
option was specified, then on normal termination of the editing process the cell's new contents will be set to the text contained in the edit window, even if it has not been changed interactively (but might have been returned by the command given by the the-editstartcommand
option).Setting this option to true enables you to execute an arbitrary action whenever the interactive cell editing is finished. Just binding a script to the
<Destroy>
event for the temporary embedded widget used for the editing won't work, because that widget might be destroyed and recreated automatically under various circumstances. Alternately, you can use the<<TablelistCellUpdated>>
and<<TablelistCellRestored>>
virtual events, generated by thefinishediting
andcancelediting
subcommands, respectively. -
Command-Line Name: -fullseparators
Database Name: fullSeparators
Database Class: FullSeparators
Specifies a boolean value that controls whether the separators (if any) shall extend all of the way to the bottom of the tablelist's body. The default is
0
, meaning that the height of the separators will be adjusted to the widget's content, i.e., they won't extend to the bottom of the tablelist's body if there is free vertical space left below the widget's last row. -
Command-Line Name: -height
Database Name: height
Database Class: Height
Specifies the desired height for the window, in units of characters in the font given by the
-font
option. This is at the same time the desired height in lines, provided that no column-, row-, or cell-specific fonts, multi-line elements, or embedded images or windows will make the height of any of the rows different from the one corresponding to the above-mentioned font. With this restriction, if the option's value is zero or less, then the window's height is made just large enough to hold all the items in the tablelist widget. -
Command-Line Name: -incrarrowtype
Database Name: incrArrowType
Database Class: IncrArrowType
Specifies the type of the arrow placed into a column label when sorting the items based on that column in increasing order, with the aid of the
sortbycolumn
orsortbycolumnlist
subcommand of the Tcl command associated with the widget. The value of this option must be one ofup
ordown
. The default isup
. This option is only relevant if the value of the-showarrow
option is true. -
Command-Line Name: -instanttoggle
Database Name: instantToggle
Database Class: InstantToggle
Specifies a boolean value that controls whether the interactive cell editing with the aid of a Tk or tile checkbutton widget, if started with the left mouse button, will be finished immediately after automatically toggling the checked state of the temporary embedded checkbutton. The default value is
0
, meaning that a mouse click into the cell will only start the editing session (and automatically toggle the checkbutton's checked state), but not also finish it. -
Command-Line Name: -labelactivebackground
Database Name: labelActiveBackground
Database Class: Foreground
Specifies the
-activebackground
option for the header labels, i.e., the background color to use when the mouse cursor is positioned over a header label and the value oftk_strictMotif
is false. This option is only defined in the Tablelist package if the Tk version being used supports the-activebackground
option for label widgets. This is checked by Tablelist at initialization time, and will normally be the case for Tk versions 8.3.2 or higher. On the other hand, the Tablelist_tile package doesn't support the-labelactivebackground
option. -
Command-Line Name: -labelactiveforeground
Database Name: labelActiveForeground
Database Class: Background
Specifies the
-activeforeground
option for the header labels, i.e., the foreground color to use when the mouse cursor is positioned over a header label and the value oftk_strictMotif
is false. This option is only defined in the Tablelist package if the Tk version being used supports the-activeforeground
option for label widgets. This is checked by Tablelist at initialization time, and will normally be the case for Tk versions 8.3.2 or higher. On the other hand, the Tablelist_tile package doesn't support the-labelactiveforeground
option. -
Command-Line Name: -labelbackground
or-labelbg
Database Name: labelBackground
Database Class: Background
Specifies the
-background
option for the header labels. This option is only supported by the Tablelist package, but not by Tablelist_tile. -
Command-Line Name: -labelborderwidth
or-labelbd
Database Name: labelBorderWidth
Database Class: BorderWidth
Specifies the
-borderwidth
option for the header labels. This option is different from the standard-borderwidth
option defined for the tablelist widget itself. In the package Tablelist_tile this option has a theme-specific default value.REMARK: Please take into account that in some themes, setting this option to a value other than the default might be ignored by tile and thus could cause alignment problems. This is because the border of tile widgets is drawn with theme-specific methods, which will not always produce the results known from Tk widgets.
-
Command-Line Name: -labelcommand
Database Name: labelCommand
Database Class: LabelCommand
Specifies the Tcl command to be invoked when mouse button 1 is pressed over one of the header labels and later released over the same label. When the
<ButtonRelease-1>
event occurs, the command is automatically concatenated with the name of the tablelist widget and the column index of the respective label, and the resulting script is evaluated in the global scope. If the tablelist'sstate
isdisabled
then this action will not take place. The most common value of this option istablelist::sortByColumn
; this command sorts the items based on the column whose index was passed to it as second argument. -
Command-Line Name: -labelcommand2
Database Name: labelCommand2
Database Class: LabelCommand2
Specifies the Tcl command to be invoked when mouse button 1 is pressed together with the
Shift
key over one of the header labels and later released over the same label. When the<ButtonRelease-1>
event occurs, the command is automatically concatenated with the name of the tablelist widget and the column index of the respective label, and the resulting script is evaluated in the global scope. If the tablelist'sstate
isdisabled
then this action will not take place. The most common value of this option istablelist::addToSortColumns
; this command adds the column index passed to it as second argument to the list of sort columns and sorts the items based on the columns indicated by the modified list. -
Command-Line Name: -labeldisabledforeground
Database Name: labelDisabledForeground
Database Class: DisabledForeground
Specifies the
-disabledforeground
option for the header labels, i.e., the foreground color to use for the labels when the tablelist'sstate
isdisabled
. This option is only defined in the Tablelist package if the Tk version being used supports the-disabledforeground
option for label widgets. This is checked by Tablelist at initialization time, and will normally be the case for Tk versions 8.3.1 or higher. On the other hand, the Tablelist_tile package doesn't support the-labeldisabledforeground
option. -
Command-Line Name: -labelfont
Database Name: labelFont
Database Class: Font
Specifies the
-font
option for the header labels. In the package Tablelist_tile this option has a theme-specific default value. -
Command-Line Name: -labelforeground
or-labelfg
Database Name: labelForeground
Database Class: Foreground
Specifies the
-foreground
option for the header labels. In the package Tablelist_tile this option has a theme-specific default value. -
Command-Line Name: -labelheight
Database Name: labelHeight
Database Class: Height
Specifies the
-height
option for the header labels. This option is only supported by the Tablelist package, but not by Tablelist_tile. -
Command-Line Name: -labelpady
Database Name: labelPadY
Database Class: Pad
In the Tablelist package this option specifies the
-pady
configuration option for the header labels. In the Tablelist_tile package the value of the-labelpady
option is mapped to the corresponding components of the value of the-padding
configuration option of the header labels, and the-labelpady
option has a theme-specific default value. -
Command-Line Name: -labelrelief
Database Name: labelRelief
Database Class: Relief
Specifies the
-relief
option for the header labels. This option is different from the standard-relief
option defined for the tablelist widget itself. The default value israised
. -
Command-Line Name: -listvariable
Database Name: listVariable
Database Class: Variable
Specifies the name of a variable. The value of the variable is a list to be displayed inside the widget; if the variable value changes then the widget will automatically update itself to reflect the new value. The value of the variable must be a valid list. Each list element corresponds to a row within the widget, and must be a valid list itself; its elements correspond to the cells within the respective row. Attempts to assign a variable whose value does not fulfil these conditions to
-listvariable
will cause an error. Attempts to unset a variable in use as a-listvariable
will fail but will not generate an error.REMARK 1: For increased efficiency, updating the widget to reflect a changed value of the variable specified with this option is, whenever possible, done at idle time (i.e., when there are no events to process). On the other hand, most tablelist subcommands make it necessary to perform an immediate update of the widget's internal list according to the value of this variable, before executing the subcommand in question. Doing this repeatedly can become quite inefficient. To avoid performance problems, you should always try to separate the operations that build up the value of the variable specified by this option from other commands. For example, instead of
tablelist::tablelist .tbl ... -listvariable var set var {} for {set row 0} {$row < 1000} {incr row} { lappend var ... .tbl cellconfigure $row,3 -image ... }
you should write
tablelist::tablelist .tbl ... -listvariable var set var {} for {set row 0} {$row < 1000} {incr row} { lappend var ... } for {set row 0} {$row < 1000} {incr row} { .tbl cellconfigure $row,3 -image ... }
The first method above is quite inefficient, because it requires 1000 updates of the widget's internal list. The second method performs incomparably faster, because it needs only one synchronization (at the beginning of the second loop).
REMARK 2: It is not recommended to set this option for a tablelist used as a tree widget, because adding new items to the list specified as its value will result in inserting those list elements into the widget without respecting the tree's internal structure. There is no problem if you access the variable for reading only, but for that purpose it is more efficient to use the
itemlistvar
subcommand rather than the-listvariable
option. -
Command-Line Name: -movablecolumns
Database Name: movableColumns
Database Class: MovableColumns
Specifies a boolean value that determines whether the columns can be moved interactively. See the DEFAULT AND INDIVIDUAL BINDINGS FOR THE HEADER LABELS section below for information on moving a column interactively. The default value is
0
. -
Command-Line Name: -movablerows
Database Name: movableRows
Database Class: MovableRows
Specifies a boolean value that determines whether the rows can be moved interactively. See the DEFAULT AND INDIVIDUAL BINDINGS FOR THE TABLELIST BODY section below for information on moving a row interactively. The default value is
0
. -
Command-Line Name: -movecolumncursor
Database Name: moveColumnCursor
Database Class: MoveColumnCursor
Specifies the mouse cursor to be used when moving a column interactively. The default value is
icon
on the windowing systemsx11
andwin32
, and the native cursorclosedhand
on the Macintosh windowing systemsclassic
andaqua
. -
Command-Line Name: -movecursor
Database Name: moveCursor
Database Class: MoveCursor
Specifies the mouse cursor to be used when moving a row interactively. The default value is
hand2
on the windowing systemsx11
andwin32
, and the native cursorpointinghand
on the Macintosh windowing systemsclassic
andaqua
. -
Command-Line Name: -populatecommand
Database Name: populateCommand
Database Class: PopulateCommand
Specifies a Tcl command to be invoked by the
searchcolumn
subcommand before examining the children (or descendants, when used with the-descend
option) of a tablelist row whose children have not been inserted yet. The specified command is automatically concatenated with the name of the tablelist widget and the row index, and the resulting script is evaluated in the global scope. It is expected that this script will insert the children of the row in question, without expanding the node or changing its appearance in any other way.For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this option is not supported for Tk versions earlier than 8.3.REMARK: There are many similarities between this option and
-expandcommand
. Both options are used in the first place to insert children on demand. The main differences between them are as follows:- The command specified by the
-populatecommand
option is only invoked for rows whose children have not been inserted yet, while the one specified by-expandcommand
is always invoked before expanding a row, regardless of whether the children of that row are already present in the widget or not. - The command specified by the
-expandcommand
option may perform visual changes on the node in question, while the role of the one specified by-populatecommand
is restricted to inserting the children, without altering the node's appearance in any way.
A logical consequence of the above is that the value of
-populatecommand
is usually just a stripped-down version of the command specified by the-expandcommand
option. For example, the Directory Viewer demo script might use a command implemented as follows:proc populateCmd {tbl row} { # Get the name of the directory whose leaf name is # displayed in the first cell of the specified row set dir [$tbl rowattrib $row pathName] # Display the contents of the directory $dir # as child items of the one identified by $row putContents $dir $tbl $row }
Moreover, the
-expandcommand
option can be set to a command that invokes the one specified by the-populatecommand
option:proc expandCmd {tbl row} { if {[$tbl childcount $row] == 0} { populateCmd $tbl $row } # The rest is just eye candy: if {[$tbl childcount $row] != 0} { # Update the image displayed in the row's first cell $tbl cellconfigure $row,0 -image openFolderImg } }
- The command specified by the
-
Command-Line Name: -protecttitlecolumns
Database Name: protectTitleColumns
Database Class: ProtectTitleColumns
Specifies a boolean value that determines whether the boundary of the title column area shall be protected from being crossed when moving a column interactively. See the DEFAULT AND INDIVIDUAL BINDINGS FOR THE HEADER LABELS section below for information on moving a column interactively. The default value is
0
, specifying that non-title columns can be moved into the title column area and vice-versa. -
Command-Line Name: -resizablecolumns
Database Name: resizableColumns
Database Class: ResizableColumns
Specifies a boolean value that determines whether the columns can be resized interactively. See the DEFAULT AND INDIVIDUAL BINDINGS FOR THE HEADER LABELS section below for information on interactive column resizing. The default value is
1
. -
Command-Line Name: -resizecursor
Database Name: resizeCursor
Database Class: ResizeCursor
Specifies the mouse cursor to be used during interactive column resizing. The default value is
sb_h_double_arrow
on the windowing systemsx11
andwin32
, and the native cursorresizeleftright
on the Macintosh windowing systemsclassic
andaqua
. -
Command-Line Name: -selectmode
Database Name: selectMode
Database Class: SelectMode
Specifies one of several styles for manipulating the selection. The value of the option may be arbitrary, but the default bindings expect it to be either
single
,browse
,multiple
, orextended
. The default value isbrowse
. -
Command-Line Name: -selecttype
Database Name: selectType
Database Class: SelectType
Specifies one of two selection types for the tablelist widget:
row
orcell
. If the selection type isrow
then the default bindings will select and deselect entire items, and the whole row having the location cursor will be displayed as active when the tablelist has the keyboard focus. If the selection type iscell
then the default bindings will select and deselect individual elements, and the single cell having the location cursor will be displayed as active when the tablelist has the keyboard focus. The default value isrow
. -
Command-Line Name: -setfocus
Database Name: setFocus
Database Class: SetFocus
Specifies a boolean value that determines whether a click with the left mouse button anywhere into the tablelist's body, including the separators and the embedded images (more precisely, any descendants of the tablelist widget having the binding tag
TablelistBody
) should set the focus to the body of the tablelist widget if the latter'sstate
isnormal
. The default value is1
. -
Command-Line Name: -showarrow
Database Name: showArrow
Database Class: ShowArrow
Specifies a boolean value that determines whether the
sortbycolumn
andsortbycolumnlist
subcommands of the Tcl command associated with the widget should place an arrow indicating the sort order into the header label(s) of the column(s) specified by their first argument. The default value is1
. -
Command-Line Name: -showeditcursor
Database Name: showEditCursor
Database Class: ShowEditCursor
Specifies a boolean value indicating whether the mouse cursor should change automatically to one having the shape of a pencil whenever a click with mouse button 1 would start an editing session. The default value is
1
.REMARK: On X11 and Mac OS X Aqua, the cursor set by Tablelist when a mouse klick would start the interactive cell editing, is Tk's built-in cursor
pencil
. Since on Windows this cursor is ugly and not really usable, the edit cursor shown by Tablelist on this platform will be the one loaded from the filepencil.cur
, located in thescripts
subdirectory of the Tablelist installation directory. If the application was started as a starpack containing the Tablelist package, then the edit cursor will be loaded from a copy of this file, created automatically by Tablelist in the user'sTemp
directory.The file
pencil.cur
is a copy of the fileUbuntu Handwriting.cur
, downloaded from the addresshttp://www.rw-designer.com/cursor-detail/46745
-
Command-Line Name: -showhorizseparator
Database Name: showHorizSeparator
Database Class: ShowHorizSeparator
Specifies a boolean value that controls whether to place a horizontal separator just below the last row if the value of the
-showseparators
option is true, that of the-fullseparators
option is false, and there is free space left between the last row and the bottom of the tablelist window. The default value is1
. -
Command-Line Name: -showlabels
Database Name: showLabels
Database Class: ShowLabels
Specifies a boolean value that determines whether the header labels are to be shown or not. The default value is
1
. -
Command-Line Name: -showseparators
Database Name: showSeparators
Database Class: ShowSeparators
Specifies a boolean value that determines whether the columns are to be separated with borders. The default value is
0
. The separators are implemented as thin frames with sunken relief in the package Tablelist, and as tile separator widgets in the package Tablelist_tile. They are attached to the right edges of the header labels, and are only created if the value of this option is true. In this case, a horizontal separator will also be created and placed just below the last row, provided that the value of the-showhorizseparator
option is true, that of the-fullseparators
option is false, and there is free space left between the last row and the bottom of the tablelist window.REMARK: Tablelist doesn't support horizontal separators (except for the one mentioned above), but a nice distinguishing effect for the rows can be achieved with the aid of the
-stripebackground
option discussed below. -
Command-Line Name: -snipstring
Database Name: snipString
Database Class: SnipString
Specifies the string to be used as snip indicator when displaying the elements that don't fit into their cells. The default is an ellipsis (
"..."
). -
Command-Line Name: -sortcommand
Database Name: sortCommand
Database Class: SortCommand
Specifies a command to be used for the comparison of the items when invoking the
sort
subcommand of the Tcl command associated with the tablelist widget. To compare two items (viewed as lists of cell contents within one row each) during thesort
operation, the command is automatically concatenated with the two items and the resulting script is evaluated. 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. -
Command-Line Name: -spacing
Database Name: spacing
Database Class: Spacing
Specifies additional space to provide above and below each row of the widget. The option's value may have any of the standard forms for screen distances. It defaults to
0
. See also the-tight
option. -
Command-Line Name: -state
Database Name: state
Database Class: State
Specifies one of two states for the tablelist widget:
normal
ordisabled
. If the widget is disabled then neither items nor columns may be inserted, deleted, updated, or moved, the items, header labels, and the up- or down-arrow are drawn in the-disabledforeground
,-labeldisabledforeground
, and-arrowdisabledcolor
color, respectively, the selection cannot be modified and is not shown (although the selection information is retained), the header labels are completely insensitive, and no interactive cell editing can be performed. In addition, in disabled state any color options specified at column, row, or cell level will be ignored. -
Command-Line Name: -stretch
Database Name: stretch
Database Class: Stretch
Specifies the columns to be stretched in order to fill the tablelist window if necessary. The option's value may be
all
or a list of column indices in any of the forms described in the COLUMN INDICES section below. In the second case, the specified column indices are replaced with their numerical equivalents, except forend
andlast
, which are viewed as dynamic column indices whose numerical equivalent (i.e., the index of the tablelist's last column) might change during program execution and therefore will be recomputed every time the columns are stretched. The list will be updated automatically whenever columns are inserted, deleted, or moved. The number of pixels by which a column is stretched is proportional to its width in pixels. The default value of this option is an empty list, meaning that no column will be stretched to eliminate the blank space that might appear at the right of the table. (Note that the blank space following the header labels is filled with a dummy, insensitive label having the same background, borderwidth, and relief as the "normal" header labels.) This option is ignored if the value of the-width
configuration option is zero or less. -
Command-Line Name: -stripebackground
or-stripebg
Database Name: stripeBackground
Database Class: Background
Specifies the background color to use when displaying the items belonging to a stripe. Each stripe is composed of the same number
stripeHeight
of consecutive viewable items, according to the value of the-stripeheight
configuration option. The firststripeHeight
viewable items are "normal" ones; they are followed by a stripe composed of the nextstripeHeight
viewable items, which in turn is followed by the same number of "normal" viewable items, and so on. In the Tablelist package and in most themes supported by Tablelist_tile, the default value is an empty string, indicating that the stripes will inherit the background color specified by the-background
configuration option. When using Tablelist_tile with thetileqt
theme then the default value is given by the global KDE optionalternateBackground
, which in turn depends on the current color scheme. In this case it is recommended to either keep that default value retrieved from KDE, or to use an explicitly specified empty string if no stripes are to be displayed. The-stripebackground
option has a higher priority than the-background
column configuration option, but a lower priority than the-background
option specified at row or cell level. -
Command-Line Name: -stripeforeground
or-stripefg
Database Name: stripeForeground
Database Class: Foreground
Specifies the foreground color to use when displaying the items belonging to a stripe. Each stripe is composed of the same number
stripeHeight
of consecutive viewable items, according to the value of the-stripeheight
configuration option. The firststripeHeight
viewable items are "normal" ones; they are followed by a stripe composed of the nextstripeHeight
viewable items, which in turn is followed by the same number of "normal" viewable items, and so on. The default value is an empty string, indicating that the stripes will inherit the foreground color specified by the-foreground
configuration option. The-stripeforeground
option has a higher priority than the-foreground
column configuration option, but a lower priority than the-foreground
option specified at row or cell level. -
Command-Line Name: -stripeheight
Database Name: stripeHeight
Database Class: StripeHeight
Specifies the number of items in each stripe. If zero or less then no stripes are displayed. The default is
1
. -
Command-Line Name: -takefocus
Database Name: takeFocus
Database Class: TakeFocus
This option determines whether the widget accepts the focus during keyboard traversal. It is almost identical to the standard option of the same name (see the options manual entry for details). The only difference is that not the widget itself but its body child (containing the items) will receive the focus during keyboard traversal with the standard keys (
Tab
andShift-Tab
). -
Command-Line Name: -targetcolor
Database Name: targetColor
Database Class: TargetColor
Specifies the color of the gap displayed in the tablelist's body or header to indicate the target position when moving a row or column interactively. The target indicator belonging to the tablelist's body can also be displayed explicitly with the aid of the
showtargetmark
subcommand, and its path name can be retrieved viatargetmarkpath
. The default value isblack
. -
Command-Line Name: -tight
Database Name: tight
Database Class: Tight
Specifies a boolean value that determines whether to eliminate the one-pixel additional space left below each tablelist row for Tk listbox compatibility. The default value is
0
, which draws a one-pixel additional space below each row, just like a Tk core listbox.REMARK: You can set this option to true and at the same time provide additional space above and below each row with the aid of the
-spacing
configuratiom option. As a result, the space below each row will be the same as above the row (and not one pixel higher). -
Command-Line Name: -titlecolumns
Database Name: titleColumns
Database Class: TitleColumns
Specifies the number of the non-scrollable columns at the left edge of the window, also called title columns. The positions of these columns will not change when adjusting the horizontal view by invoking the
scan
,seecell
,seecolumn
, orxview
subcommand. The default value is0
. The value of this option also determines the scrolling unit used by the commands mentioned above when shifting the horizontal view: if it is positive then the horizontal scrolling is performed column-wise, otherwise by character units (the width of the0
character).The end of the title column area is visualized with the aid of a separator, attached to the right edge of the header label corresponding to the last non-hidden title column. This special separator is always displayed to mark the end of the title columns (if any), independently of the value of the
-showseparators
option. The user can easily distinguish it from the other separators by means of its background color, which is different from that of the other separators.For technical reasons (the use of the
-elide
option for a text widget tag), this option is not supported for Tk versions earlier than 8.3. -
Command-Line Name: -tooltipaddcommand
Database Name: tooltipAddCommand
Database Class: TooltipAddCommand
Specifies a Tcl command to be used for displaying cell- and column label-specific balloon help. When the mouse pointer enters a cell, the command is automatically concatenated with the name of the tablelist widget and the cell's row and column indices, and the resulting script is evaluated in the global scope. Similarly, when the mouse pointer enters a header label, the command is automatically concatenated with the name of the tablelist widget, the number
-1
, and the column index of the respective label, and the resulting script is evaluated in the global scope. In both cases, the action described above is only triggered if both the value of this option and that of-tooltipdelcommand
are nonempty strings.For example, consider the procedure
tooltipAddCmd
shown below, which makes use of theDynamicHelp::add
command from the BWidget package to display the full cell and label texts as tooltips for the cells and header labels with snipped contents.proc tooltipAddCmd {tbl row col} { if {($row >= 0 && [$tbl iselemsnipped $row,$col fullText]) || ($row < 0 && [$tbl istitlesnipped $col fullText])} { DynamicHelp::add $tbl -text $fullText } }
A tablelist widget can use this procedure by specifying
... -tooltipaddcommand tooltipAddCmd -tooltipdelcommand DynamicHelp::delete
If you prefer to use the
tooltip::tooltip
command from the tooltip package contained in tklib then the procedure becomesproc tooltipAddCmd {tbl row col} { if {($row >= 0 && [$tbl iselemsnipped $row,$col fullText]) || ($row < 0 && [$tbl istitlesnipped $col fullText])} { tooltip::tooltip $tbl $fullText } }
and can be used by specifying
... -tooltipaddcommand tooltipAddCmd -tooltipdelcommand "tooltip::tooltip clear"
Please note that in the less common case that the name of your tablelist widget contains spaces, the
tooltip::tooltip clear
command won't work as expected. As a workaround you can use the slightly modified approach shown below:proc tooltipDelCmd tbl { tooltip::tooltip $tbl "" } ... -tooltipaddcommand tooltipAddCmd -tooltipdelcommand tooltipDelCmd
Both examples above make use of the
iselemsnipped
andistitlesnipped
subcommands, to make sure that the full cell and label texts will only be displayed for those cells and header labels whose contents are snipped. -
Command-Line Name: -tooltipdelcommand
Database Name: tooltipDelCommand
Database Class: TooltipDelCommand
Specifies a Tcl command to be used for removing the cell- or column label-specific balloon help. When the mouse pointer leaves a cell or a header label, the command specified by this option is automatically concatenated with the name of the tablelist widget and the resulting script is evaluated in the global scope. This action is only triggered if both the value of this option and that of
-tooltipaddcommand
are nonempty strings. Common values for this option are"DynamicHelp::delete"
(which requires the BWidget package) and"tooltip::tooltip clear"
(which requires the tooltip package contained in tklib). Their usage is shown in the examples above. -
Command-Line Name: -treecolumn
Database Name: treeColumn
Database Class: TreeColumn
Specifies the column to contain the indentations and expand/collapse controls for a tablelist used as a tree widget. The option's value may be a column index in any of the forms described in the COLUMN INDICES section below. The specified column index is replaced with its numerical equivalent, and it will be updated automatically whenever columns are inserted, deleted, or moved. The default value is
0
.For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this option is not supported for Tk versions earlier than 8.3.REMARK: Please note that the tree structure will only be displayed as expected if the column specified by this option is left-aligned. It is your responsibility to make sure that this restriction is fulfilled when using a tablelist as a tree widget.
-
Command-Line Name: -treestyle
Database Name: treeStyle
Database Class: TreeStyle
Specifies the look & feel of the column containing the indentations and expand/collapse controls for a tablelist used as a tree widget. This includes, among others, the images used for displaying the expand/collapse controls, the indentation width, and whether expand/collapse controls and indentations are to be protected when selecting a row or cell. The currently supported values are shown at a glance below:
aqua
gtk
adwaita
ubuntu
mint
mate
newWave
plastique
oxygen1
oxygen2
klearlooks
plastik
baghira
phase
winnative
winxpBlue
winxpOlive
winxpSilver
vistaAero
vistaClassic
win7Aero
win7Classic
ambiance
dust
dustSand
radiance
If the tree style is
aqua
,gtk
,adwaita
,ubuntu
,mint
,mate
,newWave
,oxygen2
,vistaAero
, orwin7Aero
, and the Tk version is either 8.6 (with built-in PNG support) or 8.5 and theimg::png
package can be loaded into the interpreter, then the images used for displaying the expand/collapse controls are PNG images with alpha channel. Otherwise (i.e., for the other tree styles or in the absence of PNG support) GIF images are used for the expand/collapse controls.The following table contains a detailed description of the tree styles, in alphabetical order:
Value Screenshot Comments adwaita
Inspired by the GTK+ 3 theme Adwaita. ambiance
Inspired by the GTK+ theme Ambiance. Recommended to be used with large fonts and images. aqua
Tablelist: Default for the windowing systems aqua
andclassic
.Tablelist_tile: Default for the themes aqua
andAquativo
.baghira
Tablelist_tile: Default for the Qt styles baghira
,cde
, andmotif
within thetileqt
theme. Also used by some flavors ofqtcurve
.dust
Inspired by the GTK+ theme Dust. Recommended to be used with large fonts and images. dustSand
Inspired by the GTK+ theme Dust Sand. Recommended to be used with large fonts and images. gtk
Tablelist: Default for the windowing system x11
.Tablelist_tile: Default for the themes blue
,clam
,classic
,default
,kroc
,sriv
,srivlg
, andstep
, as well as for the Qt stylegtk+
within thetileqt
theme.klearlooks
Inspired by the KDE 4 style Klearlooks.
Tablelist_tile: Default for the Qt style qtcurve
within thetileqt
theme.mate
Inspired by a few GTK+ themes of the MATE desktop. mint
Inspired by a few GTK+ 3 themes bundled with the Linux Mint distribution. newWave
Inspired by the GTK+ theme New Wave. oxygen1
Inspired by the KDE 4 style Oxygen. oxygen2
Tablelist_tile: Default for the Qt style oxygen
within thetileqt
theme.phase
Tablelist_tile: Default for the Qt style phase
within thetileqt
theme.plastik
Tablelist_tile: Default for the plastik
theme and the Qt styleplastik
within thetileqt
theme.plastique
Tablelist_tile: Default for the Qt style plastique
within thetileqt
theme.radiance
Inspired by the GTK+ theme Radiance. Recommended to be used with large fonts and images. ubuntu
Inspired by a couple of GTK+ 3 themes bundled with the Ubuntu Linux distribution. vistaAero
Tablelist: Default for the windowing system win32
on Windows Vista.Tablelist_tile: Default for the vista
theme on Windows Vista with the Vista Aero style.vistaClassic
Tablelist: Default for the windowing system win32
on Windows Vista with the Windows Classic style.Tablelist_tile: Default for the vista
theme on Windows Vista with the Windows Classic style.win7Aero
Tablelist: Default for the windowing system win32
on Windows 7.Tablelist_tile: Default for the vista
theme on Windows 7 with the Windows 7 Aero style.win7Classic
Tablelist: Default for the windowing system win32
on Windows 7 with the Windows Classic style.Tablelist_tile: Default for the vista
theme on Windows 7 with the Windows Classic style.winnative
Tablelist: Default for the windowing system win32
on Windows 2000 and Windows XP with the Windows Classic style.Tablelist_tile: Default for the themes alt
,keramik
,keramik_alt
,winnative
, andxpnative
with the Windows Classic style, as well as for most Qt styles within thetileqt
theme.winxpBlue
Tablelist: Default for the windowing system win32
on Windows XP with the Blue color scheme.Tablelist_tile: Default for the winxpblue
theme and thexpnative
theme on Windows XP with the Blue color scheme.winxpOlive
Tablelist: Default for the windowing system win32
on Windows XP with the Olive Green color scheme.Tablelist_tile: Default for the xpnative
theme on Windows XP with the Olive Green color scheme.winxpSilver
Tablelist: Default for the windowing system win32
on Windows XP with the Silver color scheme.Tablelist_tile: Default for the xpnative
theme on Windows XP with the Silver color scheme.For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this option is not supported for Tk versions earlier than 8.3. -
Command-Line Name: -width
Database Name: width
Database Class: Width
Specifies the desired width for the window, in average-size characters of the widget's font. If zero or less then the desired width for the window is made just large enough to hold all the columns in the tablelist widget.
- COLUMN CONFIGURATION OPTIONS
- The following options are currently supported by the
columncget
,columnconfigure
,configcolumnlist
, andconfigcolumns
commands: -
-align alignment
- Specifies how to align the elements of the column. It
must be one of
left
,right
, orcenter
. This option also refers to the column's title if the-labelalign
option hasn't been specified for the given column, or if its value is an empty string. The-align
option is tied to thealignment
element corresponding to this column in the list specifying the value of the-columns
option for the tablelist widget; changes in either will automatically be reflected in the other. -background color
or-bg color
- Specifies the normal background color to use when displaying the contents of the column.
-changesnipside boolean
- Specifies whether to override the alignment-specific default
position of the snip indicator when
displaying the elements of the column (excluding its title).
The default value is
0
, meaning that the snip string will be appended to the elements if the column's alignment isleft
orcenter
and prepended to them in case the alignment isright
. -
-changetitlesnipside boolean
- Specifies whether to override the alignment-specific default
position of the snip indicator when
displaying the column's title. The default value is
0
, meaning that the snip string will be appended to the title if the column's alignment isleft
orcenter
and prepended to it in case the alignment isright
. -editable boolean
- Specifies whether the elements of the column can be edited
interactively. The default value is
0
. The value of this option can be overridden for individual cells by using the cell configuration option of the same name. -editwindow name
- Specifies the type of the temporary embedded widget to be used
for interactive editing of the contents of the given column's
cells.
name
may be one ofentry
(which is the default),text
,spinbox
(the latter for Tk versions 8.4 or higher),checkbutton
,menubutton
,ttk::entry
,ttk::spinbox
,ttk::combobox
,ttk::checkbutton
, orttk::menubutton
(the latter five only in the presence of the tile widget engine), or the value returned by one of the registration commands for widgets from the packages BWidget, Iwidgets, combobox (by Bryan Oakley), ctext, and Mentry (or Mentry_tile). For example, you can use-editwindow ComboBox
after registering the ComboBox widget for interactive cell editing with the aid of thetablelist::addBWidgetComboBox
command. Similarly, you can use-editwindow combobox
after registering Bryan Oakley's combobox widget for interactive cell editing by invoking thetablelist::addOakleyCombobox
command. The value of this option can be overridden for individual cells by using the cell configuration option of the same name. -font font
- Specifies the font to use when displaying the contents of the column.
-foreground color
or-fg color
- Specifies the normal foreground color to use when displaying the contents of the column.
-formatcommand command
- Specifies a Tcl command to be invoked when displaying the
content of a cell within this column or adding it to the selection
when the latter is being exported. If
command
is a nonempty string, then it is automatically concatenated with the cell's text, the resulting script is evaluated in the global scope, and the return value is displayed in the cell or added to the selection instead of the original data. - For example, if a time value in seconds is being
inserted into the cell and
command
is the procedureformatDate
defined as -
proc formatDate clockVal { return [clock format $clockVal -format "%Y-%m-%d"] }
- then the text displayed in the cell will be the date in the specified format, not the time value in seconds.
- This option is also used by Tablelist when building
the return values of the
getformatted
,getformattedcolumns
, andgetformattedcells
subcommands, or searching for a text pattern passed to thesearchcolumn
subcommand with the-formatted
option. All the other subcommands, notablyget
,getcolumns
,getcells
,rowcget
,columncget
,cellcget
,sort
,sortbycolumn
,sortbycolumnlist
, andrefreshsorting
operate on the original cell text, which is contained in the widget's internal list. In the case of the above example, this will make it possible to sort the items quite easily by time, with a second's precision, even if their visual representation only contains the year, month, and day. - The
-formatcommand
option comes in handy if only images or embedded windows are to be displayed in a column but the texts associated with the cells may not simply be empty strings because they are needed for other purposes (like sorting or editing). In such cases, a procedure returning an empty string can be used as the option's value, thus making sure that the textual information contained in that column remains hidden. - The demo scripts included in the Tablelist distribution contain further examples demonstrating the use of this option. The most interesting ones are also described in Tablelist Programmer's Guide.
- In the more sophisticated case that the result of
the formatting should also depend on the cell's row, you will have
to invoke the
formatinfo
subcommand, which provides the necessary information about the cell whose content is being formatted. - Due to the
-formatcommand
column configuration option, we will distinguish between the internal value of a tablelist element and its formatted version. The latter is the result of the invocation of the script corresponding to the-formatcommand
option of the element's column, or the element itself if this option was not set for that column. Consequently, the formatted version of a tablelist item is a list comprised of the formatted elements of the original item. -hide boolean
- Specifies whether to hide the column when displaying the widget
or exporting its selection. The default value is
0
. After toggling the hidden state of a column, the<<TablelistColHiddenStateChanged>>
virtual event is generated, with its-data
option set to the numerical column index for Tk versions 8.5 or higher. -labelalign alignment
- Specifies how to align the column's title. It must be one
of
left
,right
, orcenter
, or an empty string. If this option hasn't been specified for the given column, or if its value is an empty string, then the header title will have the same alignment as the elements of the column, as given by the-align
column configuration option or by thealignment
element corresponding to this column in the list specifying the value of the-columns
global option. -labelbackground color
or-labelbg color
-labelborderwidth screenDistance
or-labelbd screenDistance
-labelcommand command
-labelcommand2 command
-labelfont fontName
-labelforeground color
or-labelfg color
-labelheight lines
-labelpady screenDistance
-labelrelief relief
- The value of each of these options may also be an empty
string. These options are the column-specific equivalents of
the global ones having the same names, described in the WIDGET-SPECIFIC OPTIONS section. They
override the options of the same names set at widget level if the
specified value is not empty. If one of these options hasn't
been specified for the given column, or if its value is an empty
string, then that option will not be used at column level; the
global option of the same name will be used instead. The
-labelactivebackground
,-labelactiveforeground
, and-labeldisabledforeground
options are only defined at widget level; there are no column configuration options with these names. The-labelbackground
and-labelheight
options are only supported by the Tablelist package, but not by Tablelist_tile. -labelimage image
- Specifies the name of the Tk image to be displayed in the
header label.
image
must be the result of an invocation of theimage create
command, or an empty string, specifying that no image is to be displayed. If the label's text is right-aligned then the image will be displayed to the right of the text, otherwise to its left. The text and the image are separated from each other by a gap corresponding to the width of a space character in the given label's font. -maxwidth width
width
must be a number. A positive value specifies the column's maximum width in average-size characters of the widget's font. Ifwidth
is negative, its absolute value is interpreted as a maximum column width in pixels. Finally, a value of zero (which is the default) specifies that the column's maximum width is to be made just large enough to hold all the elements in the column, including its header. This option is only relevant if the given column has dynamic width, i.e., if its width was set to0
.-name name
- Specifies a name associated with the column. While the
numerical index of a column might change by inserting, deleting, or
moving columns, its name remains constant and can be used as a safe
alternative column index (see the COLUMN
INDICES section for details). Similarly, it can also be
used as the second component of a cell index of the form
row,col
, as described in the CELL INDICES section. To avoid ambiguities, column names should be different from any other forms of column indices (like numbers,active
,anchor
,end
,last
,left
,right
, or any of their abbreviations). They should also be different from (any abbreviations of) the stringall
, which may be specified as the value of the-stretch
configuration option. The default value is an empty string. -resizable boolean
- Specifies whether the column can be resized
interactively. See the DEFAULT AND
INDIVIDUAL BINDINGS FOR THE HEADER LABELS section for
information on interactive column resizing. The default value
is
1
. This option is only relevant if the value of the-resizablecolumns
widget configuration option is true. -
-selectbackground color
- Specifies the background color to use when displaying the contents of a cell in the given column while the cell is selected.
-
-selectforeground color
- Specifies the foreground color to use when displaying the contents of a cell in the given column while the cell is selected.
-showarrow boolean
- Specifies whether the
sortbycolumn
command with the given column index as first argument and thesortbycolumnlist
command having the given column index as element of its first argument should place an arrow indicating the sort order into the column's label. The default value is1
. This option is only relevant if the value of the-showarrow
widget configuration option is true. -
-showlinenumbers boolean
- Specifies whether the given column should display the line
numbers (starting with 1 and ending with the number of the
non-hidden rows). The default value is
0
. - The following details assume that the given column's
-showlinenumbers
option was set to true: Associating the line numbers with the non-hidden rows takes place automatically whenever items are inserted, deleted, updated, moved, or sorted, or their-hide
option is toggled. For increased efficiency, this is done at idle time. For example, if several items are inserted into or deleted from the tablelist widget, then the necessary renumbering of the non-hidden rows will be performed as an idle callback, the next time the event loop is entered and there are no events to process. The line numbers will override any previous contents of the column's cells. They are, per default, displayed without leading zeros, but this (and the display format in general) can be changed with the aid of the-formatcommand
column configuration option. - The
sortbycolumn
andsortbycolumnlist
subcommands as well as thetablelist::sortByColumn
andtablelist::addToSortColumns
commands check the column indices passed to them as arguments and don't perform any sorting by those columns that have been configured to display the line numbers (see the corresponding descriptions for details). - REMARK: Please note that the line numbers refer to the non-hidden rows, which in case of a tablelist used as a tree widget might be different from the viewable ones. Consequently, collapsing a row will, in general, not lead to renumbering the lines (instead, it will just elide the corresponding range of line numbers).
-sortcommand command
- This option is only relevant if the value of the
-sortmode
option for the given column iscommand
. It specifies a command to be used for the comparison of the column's elements when invoking thesortbycolumn
command with the given column index as first argument or thesortbycolumnlist
command having the given column index as element of its first argument. To compare two elements during thesortbycolumn
orsortbycolumnlist
operation,command
is automatically concatenated with the two elements and the resulting script is evaluated. The script should return an integer less than, equal to, or greater than zero if the first element is to be considered less than, equal to, or greater than the second, respectively. -sortmode mode
- Specifies how to compare the column's elements when invoking
the
sortbycolumn
command with the given column index as first argument or thesortbycolumnlist
command having the given column index as element of its first argument.mode
may have any of the following values: -
ascii
Use string comparison with Unicode code-point collation order (the name is for backward-compatibility reasons). This is the default. asciinocase
This is the same as ascii
, except that comparisons are handled in a case-insensitive manner.command
Use the command specified by the -sortcommand
column configuration option to compare the column's elements.dictionary
Use dictionary-style comparison. This is the same as ascii
, except: (a) case is ignored except as a tie-breaker; (b) if two strings contain embedded numbers, the numbers compare as integers, not characters. For example,bigBoy
sorts betweenbigbang
andbigboy
, andx10y
sorts betweenx9y
andx11y
.integer
Convert the elements to integers and use integer comparison. real
Convert the elements to floating-point values and use floating-point comparison. -stretchable boolean
- Specifies whether the column is to be stretched in order to
fill the tablelist window if necessary. The value of this
option is tied to that of the
-stretch
option for the tablelist widget; changes in either will automatically be reflected in the other. -
-stripebackground color
- Specifies the background color to use when displaying the contents of a cell in the given column if the cell's row belongs to a stripe.
-
-stripeforeground color
- Specifies the foreground color to use when displaying the contents of a cell in the given column if the cell's row belongs to a stripe.
-text list
- Specifies a list of strings to be displayed in the cells of the
given column, i.e., updates the elements contained in the
column. If the tablelist's
state
isdisabled
then this option will be ignored. -title title
- Specifies the text to be displayed in the column's
header. This option is tied to the
title
element corresponding to the given column in the list specifying the value of the-columns
option for the tablelist widget; changes in either will automatically be reflected in the other. -valign verticalAlignment
- Specifies the vertical alignment of embedded images and windows
displayed in the given column. The
verticalAlignment
must be one ofcenter
(which is the default),top
, orbottom
. Especially in rows containing multi-line elements, embedded images or windows are often not as tall as the rows themselves; in such cases, this option enables you to control the column-dependent vertical alignment of these embedded objects. The value of this option can be overridden for individual cells by using the cell configuration option of the same name. -width width
width
must be a number. A positive value specifies the column's width in average-size characters of the widget's font. Ifwidth
is negative, its absolute value is interpreted as a column width in pixels. Finally, a value of zero specifies that the column's width is to be made just large enough to hold all the elements in the column, including its header (but no larger than the maximum width indicated by the-maxwidth
column configuration option). This option is tied to thewidth
element corresponding to the given column in the list specifying the value of the-columns
option for the tablelist widget; changes in either will automatically be reflected in the other.-wrap boolean
- Specifies whether to display those elements of the given column
that don't fit into their cells in word-wrapped multi-line rather
than snipped form. The default value is
0
. If the specified column has static width or a nonzero-maxwidth
value and the value of this option is true, then elements of the column that are too long to be displayed in a single line will be broken up into several lines. The same applies to the individual lines of the multi-line elements (i.e., elements containing newline characters): they will also be wrapped if necessary, thus giving rise to additional line breaks. In both cases, the line breaks are chosen at word boundaries wherever possible, and they are only used for the external representation of the strings contained in the given column, without affecting the internal contents of the cells.
- The
-background
,-font
,-foreground
,-selectbackground
,-selectforeground
,-stripebackground
, and-stripeforeground
column configuration options override the options of the same names set at widget level (but not the ones set at cell or row level) if the specified value is not an empty string. See the COLORS AND FONTS section for further details on these options. - ROW CONFIGURATION OPTIONS
- The following options are currently supported by the
rowcget
,rowconfigure
,configrowlist
, andconfigrows
commands: -
-background color
or-bg color
- Specifies the normal background color to use when displaying the contents of the row.
-font font
- Specifies the font to use when displaying the contents of the row.
-foreground color
or-fg color
- Specifies the normal foreground color to use when displaying the contents of the row.
-hide boolean
- Specifies whether to hide the row when displaying the widget or
exporting its selection. The default value is
0
. After toggling the hidden state of a row, the<<TablelistRowHiddenStateChanged>>
virtual event is generated, with its-data
option set to the numerical row index for Tk versions 8.5 or higher. - For technical reasons (the use of the
-elide
option for a text widget tag), this option is not supported for Tk versions earlier than 8.3. - CAUTION: Tk versions 8.3 - 8.4.12 had a bug that caused a segmentation fault if the whole content of a text widget was elided. This bug was also present in Tk 8.5.a1 - 8.5.a3. When using one of these earlier Tk versions, this bug will produce a crash if all the rows of a tablelist widget are hidden. It is your responsibility to avoid such situations when using a Tk version having this bug!
-name name
- Specifies a name associated with the row. While the
numerical index of a row might change by inserting, deleting, or
moving rows, or by sorting the items, its name remains constant and
can be used as a safe alternative row index (see the ROW INDICES section for details).
Similarly, it can also be used as the first component of a cell
index of the form
row,col
, as described in the CELL INDICES section. To avoid ambiguities, row names should be different from any other forms of row indices (like numbers, full keys,active
,anchor
,end
,last
,top
,bottom
, or any of their abbreviations). The default value is an empty string. -selectable boolean
- Specifies whether the elements displayed in the given row can
be selected. The default value is
1
. If the value0
was given then any attempt to select the item contained in this row with the aid of theselection set
widget command or any of its elements by using thecellselection set
command will be silently ignored; moreover, an existing old (cell) selection is removed from the row. -
-selectbackground color
- Specifies the background color to use when displaying the contents of a cell in the given row while the cell is selected.
-
-selectforeground color
- Specifies the foreground color to use when displaying the contents of a cell in the given row while the cell is selected.
-text list
- Specifies a list of strings to be displayed in the cells of the
given row, i.e., updates the item contained in the row. If
the tablelist's
state
isdisabled
then this option will be ignored.
- The
-background
,-font
,-foreground
,-selectbackground
, and-selectforeground
row configuration options override the options of the same names set at column or widget level (but not the ones set at cell level) if the specified value is not an empty string. See the COLORS AND FONTS section for further details on these options. - CELL CONFIGURATION OPTIONS
- The following options are currently supported by the
cellcget
,cellconfigure
,configcelllist
, andconfigcells
commands: -
-background color
or-bg color
- Specifies the normal background color to use when displaying the contents of the cell.
-editable boolean
- Specifies whether the contents of the cell can be edited
interactively. The default value is
0
. This option overrides the one of the same name for the column containing the given cell. -editwindow name
- Specifies the type of the temporary embedded widget to be used
for interactive editing of the cell's contents. The default
value is
entry
. This option overrides the one of the same name for the column containing the given cell, and may have the same values as its column-related counterpart. -font font
- Specifies the font to use when displaying the contents of the cell.
-foreground color
or-fg color
- Specifies the normal foreground color to use when displaying the contents of the cell.
-image image
- Specifies the name of the Tk image to be displayed in the
cell.
image
must be the result of an invocation of theimage create
command, or an empty string, specifying that no image is to be displayed. If the column containing the cell is right-aligned then the image will be displayed to the right of the cell's text, otherwise to its left. The text and the image are separated from each other by a gap of 4 pixels. If for the same cell the-window
option was specified with a nonempty value then it overrides the-image
option. If the tablelist'sstate
isdisabled
then this option will be ignored. - To display an image in a cell, Tablelist makes use of an embedded label widget (which is created on demand). This requires more memory than inserting the image directly into the tablelist's body, but has the main advantage of making it possible to adjust the width of the label containing the widget to fit into its column. This has the visual effect of cutting off part of the image from its right side. To make sure that images with transparent background will be displayed correctly, the background color of the label widgets containing the embedded images is automatically updated whenever necessary.
-
-selectbackground color
- Specifies the background color to use when displaying the contents of the cell while it is selected.
-
-selectforeground color
- Specifies the foreground color to use when displaying the contents of the cell while it is selected.
-stretchwindow boolean
- Specifies whether the width of the window embedded into the
cell shall be adapted dynamically to the width of the cell's column
if the latter is non-zero (i.e., static). The default value
is
0
. If the value of this option is true and the column was specified with a non-zero width or was resized interactively, then the width of the embedded window (if any) will be adjusted automatically so the window fills the whole horizontal space belonging to that column (except the left and right margins). Please note that in this case the cell's text will remain hidden. On the other hand, if the column is of dynamic width then this option will be ignored and both the cell's text and its embedded window (if any) will be displayed as usual. The easiest way to avoid this discrepancy is to set the cell's text to an empty string or make sure that the column's elements are always displayed as empty strings, by using the-formatcommand
column configuration option. -text text
- Specifies the string to be displayed in the given cell, i.e.,
updates the element contained in the cell. If the tablelist's
state
isdisabled
then this option will be ignored. -valign verticalAlignment
- Specifies the vertical alignment of the embedded image or
window displayed in the cell (if any). The default value is
center
. This option overrides the one of the same name for the column containing the given cell, and may have the same values as its column-related counterpart. -window command
- Specifies a Tcl command creating the window to be embedded into
the cell. The command is automatically concatenated with the
name of the tablelist widget, the cell's row and column indices, as
well as the path name of the embedded window to be created, and the
resulting script is evaluated in the global scope.
command
may also be an empty string, specifying that no embedded window is to be displayed. If the column containing the cell is right-aligned then the window will be displayed to the right of the cell's text, otherwise to its left. The text and the window are separated from each other by a gap of 4 pixels. If this option was specified with a nonempty value then it overrides the-image
cell configuration option. If the tablelist'sstate
isdisabled
then this option will be ignored. - REMARK: There are several situations where the embedded window will be destroyed and later recreated by invoking the script mentioned above. For example, when changing the value of some of the tablelist widget or column configuration options, sorting the items, or moving a row or a column, the widget's contents will be redisplayed, which makes it necessary to recreate the embedded windows. This operation won't preserve the changes made on the embedded windows after their creation. For this reason, you should avoid any changes on embedded windows outside their creation scripts.
-windowdestroy command
- Specifies a Tcl command to be invoked when a window embedded
into the cell is destroyed. The command is automatically
concatenated with the name of the tablelist widget, the cell's row
and column indices, as well as the path name of the embedded
window, and the resulting script is evaluated in the global
scope. This option provides an easy-to-use alternative to
binding a script to the embedded window's
<Destroy>
event from within its creation script, specified as the value of the-window
cell configuration option. -windowupdate command
- Specifies a Tcl command responsible for adapting the background
and foreground colors of a window embedded into the cell to the
current background and foreground colors of the cell itself.
The current cell colors depend on whether the tablelist widget's
state
isnormal
ordisabled
, whether the cell is selected, and whether its row is displayed with the colors specified by the-stripebackground
and-stripeforeground
widget or column configuration options. The command is automatically concatenated with the name of the tablelist widget, the cell's row and column indices, the path name of the embedded window, the option name-background
and the cell's current background color, as well as the option name-foreground
and the cell's current foreground color. The resulting script is then evaluated in the global scope. The specified command can use the colors passed to it as arguments to set the corresponding colors of the embedded window to the same values. - For example, if the embedded window is a text or
ctext widget and you want for its background and foreground colors
to be automatically adapted to the cell's current background and
foreground colors, then you can achieve this by setting the
-windowupdate
cell configuration option toupdateWindow
, where the latter is the procedure implemented as follows: -
proc updateWindow {tbl row col w args} { eval [list $w configure] $args }
- With Tcl/Tk 8.5 or above, you can use the more compact form
-
proc updateWindow {tbl row col w args} { $w configure {*}$args }
- In this example,
args
is a list of the form -
-background backgroundColor -foreground foregroundColor
- The
-background
,-font
,-foreground
,-selectbackground
, and-selectforeground
cell configuration options override the options of the same names set at row, column, or widget level if the specified value is not an empty string. See the COLORS AND FONTS section for further details on these options. - DESCRIPTION
- The
tablelist::tablelist
command creates a new window namedpathName
and of the classTablelist
, and makes it into a tablelist widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the tablelist such as its colors, font, and columns. Thetablelist::tablelist
command returns itspathName
argument. At the time this command is invoked, there must not exist a window namedpathName
, butpathName
's parent must exist. - A tablelist is a multi-column listbox and tree widget, implemented as a mega-widget, consisting of a body and a header. The body displays a list of items, one per line. Each item is a list of elements, which are aligned in columns. In other words, an item is the contents of a row, and an element is the text contained in a cell. The header consists of label widgets displaying the column titles. The labels can be used, among others, for interactive column resizing and column-based sorting of the items, as described below.
- Each cell and each header label of a tablelist widget can also contain an image, which is placed to the left or right of the text, depending on the column's alignment. Instead of an image, a tablelist cell can also contain an embedded window, placed to the left or right of the text, just like an embedded image.
- When a tablelist is used as a tree widget, one of its columns will display the tree hierarchy with the aid of indentations and expand/collapse controls. The Tablelist package provides a great variety of tree styles controlling the look & feel of that column, and chooses the correct default style depending on the windowing system, operating system version, and tile theme. In a tablelist used as a multi-column tree widget, every row is at the same time a tree node, having exactly one parent node and any number of child nodes. The tree's origin is the invisible root node, which has no parent itself and whose children are the top-level nodes.
- The elements of a tablelist widget can, per default, be only edited programmatically. However, interactive editing can be enabled for individual cells and for entire columns. Per default, the interactive cell editing uses a temporary embedded entry widget, thus making sure that all the validation facilities available for entry widgets can be used during the editing process. A great variety of widgets from the packages BWidget, Iwidgets, combobox (by Bryan Oakley), ctext, and Mentry (or Mentry_tile), as well as Tk core text, spinbox, checkbutton, and menubutton widgets, along with tile entry, spinbox, combobox, checkbutton, and menubutton widgets are also supported as temporary embedded widgets used for cell editing. In addition, a rich set of keyboard bindings is provided for a comfortable navigation between the editable cells.
- When first created, a new tablelist widget has no
items. Items may be added, deleted, or updated using widget
commands described below. In addition, one or more items or
elements may be selected. If a tablelist widget is exporting
its selection (see the
-exportselection
option), then it will observe the standard X11 protocols for handling the selection. Tablelist widget selections are available as typesSTRING
andUTF8_STRING
; the value of the selection will be a text built by taking all of the rows having at least one viewable selected element, joining these elements together with tabs, and the resulting strings in turn with newlines. If a tablelist widget that is exporting its selection is the selection owner and some other window claims ownership of the selection away from it, then the virtual event<<TablelistSelectionLost>>
is generated. - It is not necessary for all the elements to be
displayed in the tablelist widget at once; commands described below
may be used to change the view in the window. Tablelist
widgets allow scrolling in both directions using the standard
-xscrollcommand
and-yscrollcommand
options. They also support scanning, as described below. - Each tablelist widget, as well as each tablelist column, row, and cell may have any number of attributes, which can be used in commands that create or manipulate tablelist widgets for particular purposes.
- COLORS AND FONTS
- The
-background
,-font
,-foreground
,-selectbackground
, and-selectforeground
options can also be specified at column, row, and cell level, by using thecolumnconfigure
(orconfigcolumnlist
, orconfigcolumns
),rowconfigure
(orconfigrowlist
, orconfigrows
), andcellconfigure
(orconfigcelllist
, orconfigcells
) subcommands of the Tcl command associated with the tablelist widget. Likewise, the-stripebackground
and-stripeforeground
options can also be specified at column level. For this reason, a particular cell can have up to four values for one and the same color or font option. If these values conflict, then the option specified at the highest priority level is used. The decreasing priority order is cell, row, column, widget. - If one of these options hasn't been specified at cell, row, or column level, or if its value for that level is an empty string (this is explicitly allowed), then that option will not be used at that particular level.
- USING A TABLELIST AS MULTI-COLUMN TREE WIDGET
- When using a tablelist widget to display a tree hierarchy, there are a few rules to follow:
-
- Do not use the the widget's
-listvariable
option, or at least do not add new items to the variable specified as its value, because adding new items to that list will result in inserting those list elements into the widget without respecting the tree's internal structure. - Make sure that the column specified by the
-treecolumn
option is left-aligned so the tree structure can be displayed as expected. - Use the
insertchild(ren)
orinsertchildlist
subcommand rather thaninsert
orinsertlist
for inserting new items into the widget.
- Do not use the the widget's
- INTERACTIVE CELL EDITING
- Whether or not the contents of a cell of a tablelist widget can
be edited interactively, depends on the
-editable
option on both cell and column level. If the cell-level option was set explicitly then its value determines the editability of the cell's contents. Otherwise the value of the column-level option is used to decide whether the cell can be edited interactively. From this rule it follows that you can enable interactive cell editing for a whole column by setting its-editable
option to true. To exclude some of the column's cells from interactive editing, set their-editable
option to false. - The interactive cell editing is started by the
editcell
subcommand, which is invoked implicitly by clicking with the left mouse button into an editable cell (see the-editselectedonly
option for details) or using keyboard navigation to move from one editable cell into another. If the selection type iscell
and the location cursor is in an editable cell, then the interactive editing of the active element can also be started by pressingReturn
orKP_Enter
. Per default, theeditcell
subcommand creates a temporary entry widget and embeds it into the cell whose index was passed to it as argument. You can, however, use the-editwindow
column or cell configuration option to specify another widget instead of an entry, like a Tk core text, spinbox, checkbutton, or menubutton widget, or a tile entry, spinbox, combobox, checkbutton, or menubutton, or one of the 19 currently supported widgets from the packages BWidget, Iwidgets, combobox (by Bryan Oakley), ctext, and Mentry (or Mentry_tile). Before specifying a widget from one of these library packages as the value of the-editwindow
column or cell configuration option, you must register it for interactive cell editing by invoking the correspondingtablelist::add*
command. The above-mentioned Tk core and tile widgets are automatically registered for cell editing. - In the simplest case, the text automatically
inserted into the temporary embedded widget is the same as the text
displayed in the cell, which in turn can be the cell's contents or
the string obtained from the latter by using the
-formatcommand
option of the cell's column. However, if the value of the-editstartcommand
configuration option is a nonempty string, then the text displayed in the cell is passed to that command as its last argument (following the tablelist's path name as well as the cell's row and column indices), the resulting script is evaluated in the global scope, and the return value becomes the edit window's contents. From within this script you can invoke thecancelediting
subcommand, which destroys the temporary embedded widget and cancels the editing of its contents. The main goal of this script is, however, to enable you to define validations for the editing process. This can be done either with the aid of the options for entry validation, supported by Tk versions 8.3 and higher (see the entry reference page), or by using the widget callback package Wcb, available for Tk versions 8.0 and higher. The Iwidgets package (available for Tk versions 8.0 or higher) provides its own validation facilities, which can equally be used if the edit window is a widget belonging to that extension. In either case, you will need the path name of the temporary embedded widget or that of its entry or entry-like component; use theeditwinpath
andentrypath
subcommands to get these path names. Another purpose of the command indicated by the-editstartcommand
option is to enable you to prepare the edit window in various other ways. For example, if the latter is a combobox widget then you can set its-editable
option to false or (for a tile combobox) set its state toreadonly
, and you will have to populate its listbox component. In the same script, you can change some of the embedded widget's visual attributes (like its background, selection background, or selection foreground color). (Notice that this can also be done with the aid of the Tk option database.) - The editing of the text inserted into the edit
window uses the widget-specific bindings for mouse and keyboard
events, with a few extensions and changes, as described in the DEFAULT BINDINGS FOR INTERACTIVE CELL
EDITING section. For example, in entry or entry-like
components of the edit window,
Control-i
inserts a tab,Control-j
inserts a newline, and if the edit window is a text or ctext widget thenReturn
andKP_Enter
insert a newline character, too.Tab
andShift-Tab
are used for navigation between the editable cells, just likeAlt-Left
,Alt-Right
,Alt-Up
,Alt-Down
,Alt-Prior
,Alt-Next
,Alt-Home
, andAlt-End
(as well asControl-Home
andControl-End
, except in the case of a text or ctext widget). On Mac OS Classic and Mac OS X Aqua theCommand
key is used instead ofAlt
. The editing can be aborted with theEscape
key (or by invoking thecancelediting
subcommand) and terminated normally withReturn
orKP_Enter
(together withControl
for a text or ctext widget). The bindings for the keys used for normal termination of the editing just invoke thefinishediting
subcommand; the latter can also be called explicitly to terminate the editing programmatically. Normal termination is also triggered by clicking with the left mouse button anywhere in the tablelist's body, outside the cell just being edited, or moving into another editable cell by using keyboard navigation. If the editing was started with the left mouse button, the edit window is a Tk or tile checkbutton, and the value of the-instanttoggle
option is true, then the normal termination of the editing will take place automatically, without any user interaction. - When normal termination of the editing process
occurs, the Tcl command associated with the tablelist widget
compares the edit window's final contents to its original
one. If they are equal then the embedded widget is destroyed
and the cell's original value is restored. If the two strings
are different and the value of the
-editendcommand
configuration option is a nonempty string, then the edit window's final text is passed to that command as its last argument (following the tablelist's path name as well as the cell's row and column indices), the resulting script is evaluated in the global scope, and the return value becomes the cell's new internal contents after destroying the temporary embedded widget. The main goal of this script is to enable you to do a final validation of the edit window's contents. From within this script you can invoke therejectinput
subcommand, which prevents the script's return value from becoming the cell's new contents; this subcommand also prevents the destruction of the temporary embedded widget. Another purpose of the command indicated by the-editendcommand
option is to convert the edit window's text to the cell's new internal contents, which is necessary if, due to the-formatcommand
column configuration option, the cell's internal value is different from its external representation. See the description of the-forceeditendcommand
option for more about the invocation of the command mentioned above. - DRAG & DROP SUPPORT
- As described in detail in
the "DEFAULT AND INDIVIDUAL BINDINGS FOR THE TABLELIST BODY"
section, the default binding scripts perform an automatic
drag-friendly handling of the selection and of pointer movements
with mouse button 1 down if the tablelist widget's
-customdragsource
opton was set to true or its body component was registered as a drag source for mouse button 1 via thetkdnd::drag_source register
or the BWidgetDragSite::register
command. - On the other hand, you can also register a tablelist
widget as a TkDND drop target, by invoking the
tkdnd::drop_target register
command. Similarly, you can register the body component of a tablelist widget as a drop target for the drag & drop framework included in BWidget, with the aid of theDropSite::register
command. (Notice that for BWidget it is necessary to register the tablelist's body rather than the widget itself.) - The action to be triggered by a drop event over a
tablelist widget might depend on the row under the mouse and the
vertical position of the mouse pointer within the containing row
(if any). For example, your application might insert one or
more new siblings before or after the row in question, or a child
item having that row as parent, depending on the vertical position
of the mouse pointer within the containing row.
Alternatively, the drop event might update the item under the
mouse, using the data associated with the drag source, or perform
some other, application-specific action. In any case, you can
significantly increase the user-friendliness of your application by
displaying a target indicator (a horizontal gap or vertical bar)
before or inside the row that will be affected by the drop.
The examples below demonstrate how to achieve this for a tablelist
widget
$tbl
with the aid of theshowtargetmark
,hidetargetmark
,targetmarkpos
, andtargetmarkpath
subcommands. - TkDND EXAMPLE: For an introduction to
TkDND see the online TkDND
Tutorial by Georgios Petasis. For the following example
it is strongly recommended to use TkDND version 2.7 or later, which
can be downloaded from the location
http://sourceforge.net/projects/tkdnd/files/
package require tkdnd 2.7 tkdnd::drop_target register $tbl DND_Text bind $tbl <<DropEnter>> { onTblDropEnterOrPos %W %X %Y %a %b } bind $tbl <<DropPosition>> { onTblDropEnterOrPos %W %X %Y %a %b } bind $tbl <<DropLeave>> { %W hidetargetmark } bind $tbl <<Drop>> { onTblDrop %W %A %D } proc onTblDropEnterOrPos {tbl rootX rootY actions buttons} { global place row set y [expr {$rootY - [winfo rooty $tbl]}] foreach {place row} [$tbl targetmarkpos $y] {} if {some_optional_excluding_condition} { $tbl hidetargetmark return refuse_drop } else { $tbl showtargetmark $place $row return copy ;# for example } } proc onTblDrop {tbl action data} { handleTblDrop $tbl $data return $action }
- BWidget EXAMPLE: For an introduction to
drag & drop with BWidget see the online tutorial BWidget example: Drag and Drop Demo
by Kevin Walzer. The
DropSite::*
commands used in the following example are described in the "DropSite" reference page included in the BWidget distribution. When using this drag & drop framework, you will have to register not only the tablelist's body, but also its target indicator as drop sites, to make sure that the target mark won't get hidden by moving the mouse cursor over it with mouse button 1 down:package require BWidget foreach w [list [$tbl bodypath] [$tbl targetmarkpath]] { DropSite::register $w -dropovercmd tblDropOverCmd -dropcmd tblDropCmd \ -droptypes ... } proc tblDropOverCmd {dropTarget dragSrc event rootX rootY op dataType data} { # $event may be "enter", "motion", or "leave" set tbl [tablelist::getTablelistPath $dropTarget] if {[string equal $event "leave"]} { set newWidget [winfo containing -displayof $dropTarget $rootX $rootY] if {![string equal $newWidget [$tbl targetmarkpath]] && ![string equal $newWidget [$tbl bodypath]]} { $tbl hidetargetmark return 2 ;# refuse the drop and re-invoke the callback on motion events } } global place row set y [expr {$rootY - [winfo rooty $tbl]}] foreach {place row} [$tbl targetmarkpos $y] {} if {some_optional_excluding_condition} { $tbl hidetargetmark DropSite::setcursor dot return 2 ;# refuse the drop and re-invoke the callback on motion events } else { $tbl showtargetmark $place $row DropSite::setcursor based_arrow_down return 3 ;# accept the drop and re-invoke the callback on motion events } } proc tblDropCmd {dropTarget dragSrc rootX rootY op dataType data} { set tbl [tablelist::getTablelistPath $dropTarget] handleTblDrop $tbl $data return "" }
- In both examples above, you can restrict the type of
the supported drop target indicator by appending the argument
-horizontal
or-vertical
to the targetmarkpos invocation. When passing the-vertical
option, you will have to extend theif
statement following that subcommand invocation as follows:if {$row < 0 || some_optional_excluding_condition} {
- Both examples above invoke the
handleTblDrop
procedure, implemented as follows:proc handleTblDrop {tbl data} { $tbl hidetargetmark global place row if {[string equal $place "before"]} if {$row < [$tbl size]} { # Insert a sibling of the item indicated by $row, built from $data # (For a flat tablelist replace the following 2 lines with # "set key [$tbl insert $row ...]") set key [$tbl insertchild [$tbl parentkey $row] \ [$tbl childindex $row] ...] } else { # Append a top-level item built from $data # (For a flat tablelist replace the following line with # "set key [$tbl insert end ...]") set key [$tbl insertchild root end ...] } } else { ;# "inside" # Insert a child of the item indicated by $row, built from $data # Alternatively, update the item indicated by $row, using $data set key [$tbl insertchild $row 0 ...] $tbl expand $row -partly } . . . }
- VIRTUAL EVENTS
- Tablelist defines a few virtual events for the purposes of
notification, and makes use of the
event generate
command to send them to the tablelist widget in question (whose path name will be the value of the%W
substitution in event scripts). When using Tk 8.5 or above, most of these virtual events are generated with their-data
option set to an appropriate event-specific value. Binding scripts can access this user data as the value of the%d
substitution. Unfortunately, the-data
option toevent generate
was not supported by Tk versions earlier than 8.5. For these Tk versions, theevent generate
command will be invoked without the-data
option. - The virtual events generated by Tablelist are as follows:
-
Virtual Event Description User Data (for Tk 8.5 or Later) <<TablelistCellRestored>>
Generated by the cancelediting
subcommand.A list consisting of the numerical row and column indices of the cell whose content is being edited. <<TablelistCellUpdated>>
Generated by the finishediting
subcommand.A list consisting of the numerical row and column indices of the cell whose content is being edited. <<TablelistColHiddenStateChanged>>
Generated whenever the hidden state of one or more columns is toggled by using the columnconfigure
,configcolumnlist
,configcolumns
, ortogglecolumnhide
subcommand.A list consisting of the numerical indices of the columns whose hidden state changed. <<TablelistColumnMoved>>
Generated by the default bindings whenever a column is moved interactively to a new position. A list of length 4, whose first two elements are identical to the two arguments passed to the movecolumn
subcommand invoked for moving the source column to the target position, and the last two elements are the corresponding column names, retrieved with the aid of thecolumncget ... -name
subcommand.<<TablelistColumnResized>>
Generated by the default bindings whenever a column is resized interactively. The numerical index of the column that was resized. <<TablelistColumnSorted>>
Generated by the tablelist::sortByColumn
command.A list consisting of the numerical column index and the sort order ( decreasing
orincreasing
).<<TablelistColumnsSorted>>
Generated by the tablelist::addToSortColumns
command.A list consisting of the two lists passed to the sortbycolumnlist
subcommand, invoked to perform the multi-column sorting.<<TablelistRowHiddenStateChanged>>
Generated whenever the hidden state of one or more rows is toggled by using the rowconfigure
,configrowlist
,configrows
, ortogglerowhide
subcommand.A list consisting of the numerical indices of the rows whose hidden state changed. <<TablelistRowMoved>>
Generated by the default bindings whenever a row is moved interactively to a new position. A list of length 3, whose elements are derived from the arguments passed to the second form of the move
subcommand invoked for moving the source row to the target position. The first list element will be the full key corresponding to the first argument, the second one will beroot
or the full key corresponding to the second argument, and the third list element will be identical to the third argument passed to themove
subcommand.<<TablelistSelect>>
,<<ListboxSelect>>
Generated by the default bindings whenever the selection changes in the tablelist widget due to user interaction. Not used. <<TablelistSelectionLost>>
Sent to the tablelist widget whenever it loses ownership of the PRIMARY selection. Not used. - ROW INDICES
- Many of the widget commands for tablelist widgets take one or more row indices as arguments. A row index specifies a particular item of the tablelist, in any of the following ways:
-
number
Specifies the item as a numerical index, where 0
corresponds to the first item in the tablelist.knumber
Specifies the item by its full key, composed of the letter k
and the sequence number associated with the item. You can use thegetkeys
widget command to get this sequence number, or thegetfullkeys
widget command to retrieve the full key. In addition, theinsert
,insertlist
,insertchildren
, andinsertchildlist
subcommands return the list of full keys associated with the items just inserted.active
Indicates the item containing the element that has the location cursor. Depending on the selection type, this item as a whole or just its element having the location cursor will be displayed according to the value of the -activestyle
configuration option when the tablelist has the keyboard focus. This item is specified with theactivate
widget command or as the row containing the element specified with theactivatecell
widget command.anchor
Indicates the anchor point for the row selection, which is set with the selection anchor
widget command, or the row containing the anchor point for the cell selection, which is set with thecellselection anchor
widget command.end
Indicates the end of the tablelist. For most commands this refers to the last item in the tablelist, but for a few commands such as index
,insert
,insertlist
, andshowtargetmark before
, as well as for the target of themove
command it refers to the item just after the last one.last
Indicates the last item of the tablelist. top
Indicates the topmost item visible in the tablelist window. bottom
Indicates the bottommost item visible in the tablelist window. @x,y
Indicates the item that covers the point in the tablelist window specified by x
andy
(in pixel coordinates). If no item covers that point, then the closest item to that point is used. The coordinatesx
andy
are expected to be relative to the tablelist window itself (not its body component).name
Specifies the row by the value of its -name
configuration option.name
must be different from all the above row indices, and should be unique (if several rows have the same name then this value is considered to indicate the first matching row). - In the widget command descriptions below, arguments
named
index
,first
,last
,sourceIndex
, andtargetIndex
always contain row indices in one of the above forms. - NODE INDICES
- Many of the widget commands for tablelist widgets take a node
index as argument. A node index is either the word
root
, denoting the invisible root node of a tablelist used as a tree widget, or a regular row index in one of the above forms, specifying a particular item of the tablelist. - In the widget command descriptions below, arguments
named
nodeIndex
,parentNodeIndex
, andtargetParentNodeIndex
always contain node indices. - COLUMN INDICES
- Many of the widget commands for tablelist widgets take one or more column indices as arguments. A column index specifies a particular column of the tablelist, in any of the following ways:
-
number
Specifies the column as a numerical index, where 0
corresponds to the first column in the tablelist.active
Indicates the column containing the element that has the location cursor. If the selection type is cell
then this element will be displayed according to the value of the-activestyle
configuration option when the tablelist has the keyboard focus. This element is specified with theactivatecell
widget command.anchor
Indicates the column containing the anchor point for the cell selection, which is set with the cellselection anchor
widget command.end
Indicates the last column of the tablelist, except for the commands insertcolumns
andinsertcolumnlist
, as well as for the target of themovecolumn
command, in which cases it refers to the column just after the last one.last
Indicates the last column of the tablelist. left
Indicates the leftmost column visible in the tablelist window. right
Indicates the rightmost column visible in the tablelist window. @x,y
Indicates the column that covers the point in the tablelist window specified by x
andy
(in pixel coordinates). If no column covers that point, then the closest column to that point is used. The coordinatesx
andy
are expected to be relative to the tablelist window itself (not its body component).name
Specifies the column by the value of its -name
configuration option.name
must be different from all the above column indices, and should be unique (if several columns have the same name then this value is considered to indicate the first matching column). - In the widget command descriptions below, arguments
named
columnIndex
,firstColumn
,lastColumn
,sourceColumn
, andtargetColumn
always contain column indices in one of the above forms. - CELL INDICES
- Many of the widget commands for tablelist widgets take one or more cell indices as arguments. A cell index specifies a particular cell of the tablelist, in any of the following ways:
-
row,col
Indicates the cell having the row index row
and column indexcol
.row
may be a number, a full key (of the formknumber
),active
,anchor
,end
(where the latter indicates the last row in the tablelist),last
,top
,bottom
, or a row name.col
may be a number,active
,anchor
,end
,last
,left
,right
, or a column name.active
Indicates the element that has the location cursor. If the selection type is cell
then this element will be displayed according to the value of the-activestyle
configuration option when the tablelist has the keyboard focus. This element is specified with theactivatecell
widget command.anchor
Indicates the anchor point for the cell selection, which is set with the cellselection anchor
widget command.end
Indicates the last cell in the last row of the tablelist. last
Indicates the last cell in the last row of the tablelist (same as end
).@x,y
Indicates the cell that covers the point in the tablelist window specified by x
andy
(in pixel coordinates). If no cell covers that point, then the closest cell to that point is used. The coordinatesx
andy
are expected to be relative to the tablelist window itself (not its body component). - In the widget command descriptions below, arguments
named
cellIndex
,firstCell
, andlastCell
always contain cell indices in one of the above forms. - WIDGET COMMAND
- The
tablelist::tablelist
command creates a new Tcl command whose name ispathName
. This command may be used to invoke various operations on the widget. It has the following general form:pathName option ?arg arg ...?
option
and thearg
s determine the exact behavior of the command. The following commands are possible for tablelist widgets:-
pathName activate index
- Sets the active item to the one indicated by
index
if the tablelist'sstate
is notdisabled
. Ifindex
is outside the range of items in the tablelist or it refers to a non-viewable item then the closest viewable item is activated. The active item is drawn as specified by the-activestyle
configuration option when the widget has the input focus and the selection type isrow
. Its index may be retrieved with the indexactive
. Returns an empty string. pathName activatecell cellIndex
- Sets the active element to the one indicated by
cellIndex
if the tablelist'sstate
is notdisabled
. IfcellIndex
is outside the range of elements in the tablelist or it refers to a non-viewable element, then the closest viewable element is activated. The active element is drawn as specified by the-activestyle
configuration option when the widget has the input focus and the selection type iscell
. Its index may be retrieved with the cell indexactive
. Returns an empty string. pathName applysorting itemList
- Sorts the elements of
itemList
according to the parameters of the most recentsort
,sortbycolumn
, orsortbycolumnlist
invocation and returns a new list in sorted order. TheitemList
argument is supposed to be a well-formed list of lists, where the length of each sublist is expected to be no less than the number of columns of the tablelist widget. If the items haven't been sorted at all, or the sort information was reset by invokingresetsortinfo
, then no sorting takes place and the return value will be identical toitemList
. - REMARK: This subcommand is usually
invoked from within the command specified as the value of the
-expandcommand
configuration option, for a tablelist row whose children have not yet been inserted into the widget. The most efficient way to insert the child items in the correct order is to add them to a list, sort this list viaapplysorting
, and then insert the items of the sorted list by invoking theinsertchildlist
subcommand. pathName attrib ?name? ?value name value ...?
- Queries or modifies the attributes of the widget. If no
name
is specified, the command returns a list of pairs, each of which contains the name and the value of an attribute forpathName
. Ifname
is specified with novalue
, then the command returns the value of the one named attribute, or an empty string if no corresponding value exists (you can use thehasattrib
subcommand to distinguish this case from the one that the value of an existing attribute is an empty string). If one or morename
-value
pairs are specified, then the command sets the given widget attribute(s) to the given value(s); in this case the return value is an empty string.name
may be an arbitrary string. pathName bbox index
- Returns a list of four numbers describing the bounding box of
the row given by
index
. The first two elements of the list give the x and y coordinates of the upper-left corner of the screen area covered by the row (specified in pixels relative to the widget) and the last two elements give the width and height of the area, in pixels. If no part of the row given byindex
is visible on the screen, or ifindex
refers to a non-existent row, then the result is an empty string; if the row is partially visible, the result gives the full area of the row, including any parts that are not visible. pathName bodypath
- Returns the path name of the body component of the widget.
pathName bodytag
- Returns the name of a binding tag whose name depends on the
path name of the tablelist widget and which is associated with the
tablelist's body, the separators, as well as the message and label
widgets used for displaying multi-line elements and images,
respectively. This binding tag precedes the tag
TablelistBody
in the list of binding tags of the tablelist descendants mentioned above, and is designed to be used when defining individual binding scripts for tablelist widgets. The main advantage of using this tag instead of the path name of the tablelist's body is that it enables you to write event handling scripts that are valid not only for the tablelist's body but also for the separators, multi-line cells, and embedded images. pathName canceledediting
- Returns the value
1
if the most recent interactive cell editing was canceled (by the user or programmatically, with the aid of thecancelediting
subcommand) and0
otherwise. - REMARK: By invoking this subcommand
from within the Tcl command specified by the
-editendcommand
configuration option, you can find out whether the editing session was canceled or terminated normally. Remember that this Tcl command will be invoked in both cases mentioned above if the-forceeditendcommand
option was set to true. pathName cancelediting
- This subcommand cancels the interactive editing of the contents
of the cell whose index was passed to the
editcell
subcommand, destroys the temporary widget embedded into the cell, and restores the original cell contents. This command enables you to cancel the interactive cell editing from within the Tcl command specified by the-editstartcommand
configuration option if that pre-edit callback encounters an error when preparing the text to be inserted into the edit window. The command is also invoked implicitly by pressing theEscape
key when a cell is being edited. The return value is an empty string. Immediately before returning this value, the command generates the virtual event<<TablelistCellRestored>>
. For Tk versions 8.5 or higher, this virtual event is generated with its-data
option set to a list consisting of the numerical row and column indices of the cell whose content is being edited. If no cell was being edited when the command was invoked then an empty string is returned without generating a virtual event. pathName cellattrib cellIndex ?name? ?value name value ...?
- Queries or modifies the attributes of the cell given by
cellIndex
. If noname
is specified, the command returns a list of pairs, each of which contains the name and the value of an attribute for the cell. Ifname
is specified with novalue
, then the command returns the value of the one named cell attribute, or an empty string if no corresponding value exists (you can use thehascellattrib
subcommand to distinguish this case from the one that the value of an existing cell attribute is an empty string). If one or morename
-value
pairs are specified, then the command sets the given cell attribute(s) to the given value(s); in this case the return value is an empty string.name
may be an arbitrary string. pathName cellbbox cellIndex
- Returns a list of four numbers describing the bounding box of
the cell given by
cellIndex
. The first two elements of the list give the x and y coordinates of the upper-left corner of the screen area covered by the cell (specified in pixels relative to the widget) and the last two elements give the width and height of the area, in pixels. If no part of the cell given bycellIndex
is visible on the screen, or ifcellIndex
refers to a non-existent cell, then the result is an empty string; if the cell is partially visible, the result gives the full area of the cell, including any parts that are not visible. pathName cellcget cellIndex option
- Returns the current value of the cell configuration option
given by
option
for the cell specified bycellIndex
.option
may have any of the values accepted by thecellconfigure
command. pathName cellconfigure cellIndex ?option? value option value ...?
- Queries or modifies the configuration options of the cell given
by
cellIndex
. If nooption
is specified, the command returns a list describing all of the available options for the cell (seeTk_ConfigureInfo
for information on the format of this list). Ifoption
is specified with novalue
, 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 nooption
is specified). If one or moreoption
-value
pairs are specified, then the command modifies the given cell option(s) to have the given value(s); in this case the return value is an empty string.option
may have any of the values described in the CELL CONFIGURATION OPTIONS section. pathName cellindex cellIndex
- Returns the canonical cell index value that corresponds to
cellIndex
, in the formrow,col
, whererow
andcol
are integers. pathName cellselection option args
- This command is used to adjust the cell selection within a
tablelist widget. It has several forms, depending on
option
: -
pathName cellselection anchor cellIndex
- Sets the cell selection anchor to the element given by
cellIndex
. IfcellIndex
refers to a nonexistent or non-viewable element, then the closest viewable element is used. The cell selection anchor is the end of the cell selection that is fixed while dragging out a cell selection with the mouse if the selection type iscell
. The cell indexanchor
may be used to refer to the anchor element. pathName cellselection clear firstCell lastCell
pathName cellselection clear cellIndexList
- If any of the elements between
firstCell
andlastCell
(inclusive) or corresponding to the cell indices specified by the listcellIndexList
are selected, they are deselected. The selection state is not changed for elements outside the range given in the first form of the command or different from those specified by the cell index list given in its second form. pathName cellselection includes cellIndex
- Returns
1
if the element indicated bycellIndex
is currently selected,0
if it isn't. pathName cellselection set firstCell lastCell
pathName cellselection set cellIndexList
- Selects all of the selectable elements in the range
between
firstCell
andlastCell
, inclusive, or corresponding to the indices specified by the listcellIndexList
, without affecting the selection state of any other elements. An element is viewed as selectable if and only if the value of the-selectable
option of the row containing it is true.
- If the tablelist's
state
isdisabled
andoption
is different fromincludes
then the command just returns an empty string, without performing any of the above actions. pathName cget option
- Returns the current value of the configuration option given by
option
, which may have any of the values accepted by thetablelist::tablelist
command. pathName childcount nodeIndex
- Returns the number of children of the tree node indicated by
nodeIndex
. If this argument is specified asroot
then the return value will be the number of top-level items of the tablelist widget. pathName childindex index
- Returns the numerical index of the row given by
index
in the list of children of its parent node. pathName childkeys nodeIndex
- Returns the list of full keys of the children of the tree node
indicated by
nodeIndex
. If this argument is specified asroot
then the return value will be the list of full keys of the top-level items contained in the tablelist widget. pathName collapse index ?-fully|-partly?
- This subcommand collapses the specified row of a tablelist used
as a tree widget, i.e., elides all its descendants. The
optional argument
-fully
(which is the default) indicates that the command will be performed recursively, i.e., all of the descendants of the node specified byindex
will be collapsed, so that a subsequent invocation of the non-recursive version of theexpand(all)
subcommand will only display the row's children but no further descendants of it. The-partly
option (which is used by the default bindings) restricts the operation to just one hierarchy level, implying that by a subsequent invocation of the non-recursive version of theexpand(all)
subcommand exactly the same descendants will be displayed again that were visible prior to collapsing the row. - Before hiding the descendants of a row, the command
specified as the value of the
-collapsecommand
option (if any) is automatically concatenated with the name of the tablelist widget and the row index, and the resulting script is evaluated in the global scope. - For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this subcommand is not supported for Tk versions earlier than 8.3. pathName collapseall ?-fully|-partly?
- This subcommand collapses all top-level rows of a tablelist
used as a tree widget, i.e., elides all their descendants.
The optional argument
-fully
(which is the default) indicates that the command will be performed recursively, i.e., all of the descendants of the top-level nodes will be collapsed, so that a subsequent invocation of the non-recursive version of theexpandall
subcommand will only display ther children but no further descendants of them. The-partly
option restricts the operation to just one hierarchy level, implying that by a subsequent invocation of the non-recursive version of theexpandall
subcommand exactly the same items will be displayed again that were visible prior to collapsing the top-level ones. - Before hiding the descendants of a row, the command
specified as the value of the
-collapsecommand
option (if any) is automatically concatenated with the name of the tablelist widget and the row index, and the resulting script is evaluated in the global scope. - For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this subcommand is not supported for Tk versions earlier than 8.3. pathName columnattrib columnIndex ?name? ?value name value ...?
- Queries or modifies the attributes of the column given by
columnIndex
. If noname
is specified, the command returns a list of pairs, each of which contains the name and the value of an attribute for the column. Ifname
is specified with novalue
, then the command returns the value of the one named column attribute, or an empty string if no corresponding value exists (you can use thehascolumnattrib
subcommand to distinguish this case from the one that the value of an existing column attribute is an empty string). If one or morename
-value
pairs are specified, then the command sets the given column attribute(s) to the given value(s); in this case the return value is an empty string.name
may be an arbitrary string. pathName columncget columnIndex option
- Returns the current value of the column configuration option
given by
option
for the column specified bycolumnIndex
.option
may have any of the values accepted by thecolumnconfigure
command. pathName columnconfigure columnIndex ?option? ?value option value ...?
- Queries or modifies the configuration options of the column
given by
columnIndex
. If nooption
is specified, the command returns a list describing all of the available options for the column (seeTk_ConfigureInfo
for information on the format of this list). Ifoption
is specified with novalue
, 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 nooption
is specified). If one or moreoption
-value
pairs are specified, then the command modifies the given column option(s) to have the given value(s); in this case the return value is an empty string.option
may have any of the values described in the COLUMN CONFIGURATION OPTIONS section. pathName columncount
- Returns the number of columns in the tablelist widget.
pathName columnindex columnIndex
- Returns the integer column index value that corresponds to
columnIndex
. pathName columnwidth columnIndex ?-requested|-stretched|-total?
- Returns the current width in pixels of the column specified by
columnIndex
. If the optional argument is-requested
(which is the default) then the return value is the number of pixels corresponding to the column width specified by the-columns
widget or-width
column configuration option (possibly overridden by interactive column resizing); if the column width was specified as0
(and was not changed by interactive column resizing) then the return value is the actual number of pixels corresponding to the widest viewable element of the column, including its header. With the-stretched
option, the command returns the column width obtained by increasing the value described above by the number of additional pixels that might have been added to the requested column width by a stretch operation (see the-stretch
widget and-stretchable
column configuration options). Finally, if the optional argument is-total
then the return value is the stretched column width increased by the number of pixels corresponding to the left and right margins within the column; this value equals the width of the header label if the tablelist widget is mapped. pathName configcelllist cellConfigSpecList
- For each cell index, option, and value specified by the list
cellConfigSpecList
, the command modifies the given option of the given cell to have the given value. The argumentcellConfigSpecList
must be a list of the formcellIndex option value cellIndex option value ...
- where each
option
may have any of the values described in the CELL CONFIGURATION OPTIONS section. The return value is an empty string. - This command has the same effect as
eval [list pathName configcells] cellConfigSpecList
- but it is more efficient and easier to use.
pathName configcells ?cellIndex option value cellIndex option value ...?
- For each
cellIndex
,option
, andvalue
, the command modifies the given option of the given cell to have the given value. Eachoption
may have any of the values described in the CELL CONFIGURATION OPTIONS section. The return value is an empty string. pathName configcolumnlist columnConfigSpecList
- For each column index, option, and value specified by the list
columnConfigSpecList
, the command modifies the given option of the given column to have the given value. The argumentcolumnConfigSpecList
must be a list of the formcolumnIndex option value columnIndex option value ...
- where each
option
may have any of the values described in the COLUMN CONFIGURATION OPTIONS section. The return value is an empty string. - This command has the same effect as
eval [list pathName configcolumns] columnConfigSpecList
- but it is more efficient and easier to use.
pathName configcolumns ?columnIndex option value columnIndex option value ...?
- For each
columnIndex
,option
, andvalue
, the command modifies the given option of the given column to have the given value. Eachoption
may have any of the values described in the COLUMN CONFIGURATION OPTIONS section. The return value is an empty string. pathName configrowlist rowConfigSpecList
- For each row index, option, and value specified by the list
rowConfigSpecList
, the command modifies the given option of the given row to have the given value. The argumentrowConfigSpecList
must be a list of the formindex option value index option value ...
- where each
option
may have any of the values described in the ROW CONFIGURATION OPTIONS section. The return value is an empty string. - This command has the same effect as
eval [list pathName configrows] rowConfigSpecList
- but it is more efficient and easier to use.
pathName configrows ?index option value index option value ...?
- For each
index
,option
, andvalue
, the command modifies the given option of the given row to have the given value. Eachoption
may have any of the values described in the ROW CONFIGURATION OPTIONS section. The return value is an empty string. pathName configure ?option? ?value option value ...?
- Queries or modifies the configuration options of the
widget. If no
option
is specified, the command returns a list describing all of the available options forpathName
(seeTk_ConfigureInfo
for information on the format of this list). Ifoption
is specified with novalue
, 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 nooption
is specified). If one or moreoption
-value
pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the return value is an empty string.option
may have any of the values accepted by thetablelist::tablelist
command. pathName containing y
- Given a y-coordinate within the tablelist window, this command
returns the index of the tablelist item containing that
y-coordinate. If no corresponding item is found then the
return value is
-1
. The coordinatey
is expected to be relative to the tablelist window itself (not its body component). pathName containingcell x y
- Given an x- and a y-coordinate within the tablelist window,
this command returns the index of the tablelist cell containing the
point having these coordinates. If no corresponding cell is
found then the row or column component (or both) of the return
value is
-1
. The coordinatesx
andy
are expected to be relative to the tablelist window itself (not its body component). pathName containingcolumn x
- Given an x-coordinate within the tablelist window, this command
returns the index of the tablelist column containing that
x-coordinate. If no corresponding column is found then the
return value is
-1
. The coordinatex
is expected to be relative to the tablelist window itself (not its body component). pathName cornerlabelpath
- Returns the path name of the label widget contained in the
corner frame (see the
cornerpath
subcommand. When using Tablelist_tile, the return value will be a ttk::label widget of the same style as the header labels. The global visual options set for the header labels are automatically applied to this (ttk::)label widget, too. pathName cornerpath
- Returns the path name of a frame widget that is a sibling of
the tablelist and is automatically created and destroyed together
with the latter's header. This frame is called the corner
frame, because it is designed to be shown to the right of the
tablelist widget's top-right corner when managing the vertical
scrollbar on Mac OS X Aqua (see below). The corner frame
contains a label or ttk::label widget, depending on whether the
package Tablelist or Tablelist_tile is being used (see the
cornerlabelpath
subcommand). Whenever the height of the tablelist's header changes, the height of the corner frame as well as that of the above-mentioned (ttk::)label widget is updated accordingly. - REMARK: This subcommand enables you to
manage the vertical scrollbar (if any) to appear below the
tablelist widget's header, thus respecting the native look &
feel on Mac OS X Aqua. As shown in the following example, it
is recommended to always create a scrolled tablelist along with the
scrollbar(s) as children of a (ttk::)frame widget:
# Add some entries to the Tk option database set winSys [tk windowingsystem] if {[string compare $winSys "x11"] != 0} { option add *ScrollArea.borderWidth 1 option add *ScrollArea.relief sunken option add *ScrollArea.Tablelist.borderWidth 0 option add *ScrollArea.Tablelist.highlightThickness 0 } . . . # Create the tablelist and the scrollbars as # children of a frame of class ScrollArea set frm [(ttk::)frame ... -class ScrollArea] set tbl $frm.tbl set vsb $frm.vsb set hsb $frm.hsb tablelist::tablelist $tbl ... \ -xscrollcommand [list $hsb set] -yscrollcommand [list $vsb set] scrollbar $vsb -orient vertical -command [list $tbl yview] scrollbar $hsb -orient horizontal -command [list $tbl xview] . . . # Manage the widgets within the frame grid $tbl -row 0 -rowspan 2 -column 0 -sticky news if {[string compare $winSys "aqua"] == 0} { grid [$tbl cornerpath] -row 0 -column 1 -sticky ew grid $vsb -row 1 -column 1 -sticky ns } else { grid $vsb -row 0 -rowspan 2 -column 1 -sticky ns } grid $hsb -row 2 -column 0 -sticky ew grid rowconfigure $frm 1 -weight 1 grid columnconfigure $frm 0 -weight 1 # Manage the frame pack $frm -expand yes -fill both
pathName curcellselection
- Returns a list containing the canonical indices (of the form
row,col
, whererow
andcol
are numbers) of all of the elements in the tablelist that are currently selected. If there are no such elements in the tablelist then an empty string is returned. pathName curselection
- Returns a list containing the numerical indices of all of the items in the tablelist that contain at least one selected element. If there are no such items in the tablelist then an empty string is returned.
pathName delete first last
pathName delete indexList
- Deletes one or more items of the tablelist if its
state
is notdisabled
. In the first form of the command,first
andlast
are indices specifying the first and last items in the range to delete. The command's second form accepts a listindexList
of indices specifying the items to be deleted. In both cases, all descendants of the specified items will be deleted, too. The return value is an empty string. pathName deletecolumns firstColumn lastColumn
pathName deletecolumns columnIndexList
- Deletes one or more columns of the tablelist if its
state
is notdisabled
. In the first form of the command,firstColumn
andlastColumn
are indices specifying the first and last columns in the range to delete. The command's second form accepts a listcolumnIndexList
of indices specifying the columns to be deleted. Returns an empty string. pathName depth nodeIndex
- Returns the number of steps from the tree node indicated by
nodeIndex
to theroot
node. The latter's depth is 0, that of the top-level rows is 1, and so on. pathName descendantcount nodeIndex
- Returns the number of descendants of the tree node indicated by
nodeIndex
. If this argument is specified asroot
then the return value will be the number of items of the tablelist widget. pathName editcell cellIndex
- Starts the interactive editing of the cell's contents if the
tablelist's
state
is notdisabled
and the cell is viewable and editable. Returns an empty string. See the INTERACTIVE CELL EDITING section for details on editablity and on the editing process. pathName editinfo
- Returns a three-element list containing information about the
tablelist cell whose content is being edited. The first
element of the list is the full key (of the form
knumber
) associated with the item containing the tablelist element that is being edited. The second and third elements are the cell's row and column indices. If currently no cell is being edited then the return value is the list{"" -1 -1}
. pathName editwinpath
- Returns the path name of the temporary embedded widget used for
interactive cell editing, created by the
editcell
subcommand. If no cell is currently being edited then the return value is an empty string. This subcommand enables you to access the edit window from within the commands specified by the-editstartcommand
and-editendcommand
configuration options. pathName editwintag
- Returns the name of a binding tag whose name depends on the
path name of the tablelist widget and which is associated with some
of the components of the temporary embedded widget used for
interactive cell editing. These components depend on the edit
window: the widget itself in case of a Tk or tile checkbutton or
menubutton; the edit window's entry children in case of a mentry
widget; the only entry or entry-like component of the edit window
in all other cases (see also the
entrypath
subcommand). This binding tag precedes the tagTablelistEdit
in the list of binding tags of the edit window components mentioned above, and is designed to be used when defining individual binding scripts for controlling the interactive cell editing. - For example, the following command will replace the
standard behavior of the
Return
key during cell editing in the tablelist widget.tbl
with that of theTab
key:bind [.tbl editwintag] <Return> "[bind TablelistEdit <Tab>]; break"
pathName entrypath
- Returns the path name of the entry or entry-like component of
the temporary embedded widget used for interactive cell editing,
created by the
editcell
subcommand. If no cell is currently being edited or the editing is taking place with the aid of a Tk or tile checkbutton, Tk or tile menubutton, or mentry widget, then the return value is an empty string; otherwise it is the path name of a Tk or tile entry, text or ctext, Tk or tile spinbox, or BWidget Entry widget, which can be the edit window itself or one of its descendants. This subcommand enables you to access the entry or entry-like component of the temporary embedded widget from within the commands specified by the-editstartcommand
and-editendcommand
configuration options. pathName expand index ?-fully|-partly?
- This subcommand expands the specified row of a tablelist used
as a tree widget, i.e., makes all its children visible. The
optional argument
-fully
(which is the default) indicates that the command will be performed recursively, i.e., all of the descendants of the node specified byindex
will be displayed. The-partly
option (which is used by the default bindings) restricts the operation to just one hierarchy level, indicating that only the children of the specified node will be displayed, without changing the expanded/collapsed state of the child nodes. - Before displaying the children of a row, the command
specified as the value of the
-expandcommand
option (if any) is automatically concatenated with the name of the tablelist widget and the row index, and the resulting script is evaluated in the global scope. This enables you to insert a tree node's children on demand, just before expanding it. - For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this subcommand is not supported for Tk versions earlier than 8.3. pathName expandall ?-fully|-partly?
- This subcommand expands all top-level rows of a tablelist used
as a tree widget, i.e., makes all their children visible. The
optional argument
-fully
(which is the default) indicates that the command will be performed recursively, i.e., all of the descendants of the top-level nodes will be displayed. The-partly
option restricts the operation to just one hierarchy level, indicating that only the children of the top-level nodes will be displayed, without changing the expanded/collapsed state of the child nodes. - Before displaying the children of a row, the command
specified as the value of the
-expandcommand
option (if any) is automatically concatenated with the name of the tablelist widget and the row index, and the resulting script is evaluated in the global scope. This enables you to insert a tree node's children on demand, just before expanding it. - For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this subcommand is not supported for Tk versions earlier than 8.3. pathName expandedkeys
- Returns the list of full keys of the expanded items.
pathName fillcolumn columnIndex text
- Sets all the elements of the specified column to the value
text
. pathName findcolumnname name
- Returns the index of the first column whose name (given by the
-name
column configuration option) equalsname
. If no column has the specified name then the return value is-1
. pathName findrowname name ?-descend? ?-parent nodeIndex?
- Returns the row index of the first child of the tree node
indicated by
nodeIndex
whose name (given by the-name
row configuration option) equalsname
. The-descend
option extends the search to all descendants of the tree node given by the-parent
option. The default is to restrict the search to the parent node's children only. The default parent isroot
. When searching for the given name, the items will be visited in the order of their row indices. If none of the relevant rows has the specified name then the return value is-1
. pathName finishediting
- This subcommand attempts to terminate the interactive editing
of the contents of the cell whose index was passed to the
editcell
subcommand by destroying the temporary widget embedded into the cell and updating the cell's contents. The exact steps involved are as follows: First, the widget's final text is compared to its original one. If they are equal then the edit window is destroyed and the cell's original contents are restored. If the two strings are different and the value of the-editendcommand
configuration option is a nonempty string, then the widget's final text is passed to that command as its last argument (following the tablelist's path name as well as the cell's row and column indices), the resulting script is evaluated in the global scope, and the return value becomes the cell's new contents after destroying the edit window. However, if from within this script therejectinput
subcommand was invoked then the cell's value is not changed and the embedded widget remains displayed in the cell; in this case the command returns the boolean value0
. In all the other cases, the return value is1
. Immediately before returning the value1
, the command generates the virtual event<<TablelistCellUpdated>>
. For Tk versions 8.5 or higher, this virtual event is generated with its-data
option set to a list consisting of the numerical row and column indices of the cell whose content is being edited. If no cell was being edited when the command was invoked then the same value1
is returned but no virtual event is generated. - This subcommand is called implicitly by
pressing
Return
orKP_Enter
(together withControl
if the edit window is a text or ctext widget) when editing a cell, or by clicking with the left mouse button anywhere in the tablelist's body, outside the cell just being edited, or moving into another editable cell by using keyboard navigation. If the editing was started with the left mouse button, the edit window is a Tk or tile checkbutton, and the value of the-instanttoggle
option is true, then this subcommand will be invoked automatically, without any user interaction. - REMARK: There are also situations where an explicit invocation of this subcommand is needed, in order to make sure that the cell just being edited gets updated with the text entered by the user. For example, if a tablelist widget is part of a dialog used for editing some data, then the command associated with the button designed to accept the data should call this subcommand, because otherwise, if the button is pressed during interactive cell editing then the text entered into the edit window will get lost.
pathName formatinfo
- This command is designed to be invoked from within a Tcl
command specified as the value of the
-formatcommand
column configuration option. It returns a three-element list containing information about the tablelist cell whose content is being formatted with the aid of that command. The first element of the list is the full key (of the formknumber
) associated with the item containing the tablelist element that is being formatted. The second and third elements are the cell's row and column indices. - REMARK: This subcommand is needed in
cases where the result of the formatting should depend on the
cell's row. To be able to use it, specify the value of the
-formatcommand
column configuration option as[list formatCommand pathName]
, like in the following example:.tbl columnconfigure 1 -formatcommand [list formatValue .tbl] proc formatValue {tbl val} { # Get information about the cell whose content is being formatted foreach {key row col} [$tbl formatinfo] {} # Return a string depending on $val and $row (or $key) . . . }
pathName get first last
pathName get indexList
- The first form of the command returns a list whose elements are
all of the tablelist items (i.e., row contents) between
first
andlast
, inclusive. The value returned by the second form depends on the number of elements in the listindexList
: if the latter contains exactly one index then the return value is the tablelist item indicated by that index (or an empty string if the index refers to a non-existent item); otherwise the command returns the list of all of the tablelist items corresponding to the indices specified byindexList
. pathName getcells firstCell lastCell
pathName getcells cellIndexList
- The first form of the command returns a list whose elements are
all of the tablelist elements (i.e., cell contents) between
firstCell
andlastCell
, inclusive. The value returned by the second form depends on the number of elements in the listcellIndexList
: if the latter contains exactly one cell index then the return value is the tablelist element indicated by that cell index; otherwise the command returns the list of all of the tablelist elements corresponding to the cell indices specified bycellIndexList
. pathName getcolumns firstColumn lastColumn
pathName getcolumns columnIndexList
- The first form of the command returns a list whose elements are
lists themselves, where each of the sublists corresponds to exactly
one column between
firstColumn
andlastColumn
, inclusive, and consists of all of the tablelist elements contained in that column. The value returned by the second form depends on the number of elements in the listcolumnIndexList
: if the latter contains exactly one column index then the return value is a list consisting of all of the tablelist elements contained in the column indicated by that column index; otherwise the command returns a list whose elements are lists themselves, where each of the sublists corresponds to exactly one column index incolumnIndexList
and consists of all of the tablelist elements contained in that column. pathName getformatted first last
pathName getformatted indexList
- The first form of the command returns a list whose elements are
all of the formatted tablelist items
(i.e., formatted row contents) between
first
andlast
, inclusive. The value returned by the second form depends on the number of elements in the listindexList
: if the latter contains exactly one index then the return value is the formatted tablelist item indicated by that index (or an empty string if the index refers to a non-existent item); otherwise the command returns the list of all of the formatted tablelist items corresponding to the indices specified byindexList
. pathName getformattedcells firstCell lastCell
pathName getformattedcells cellIndexList
- The first form of the command returns a list whose elements are
all of the formatted tablelist
elements (i.e., formatted cell contents) between
firstCell
andlastCell
, inclusive. The value returned by the second form depends on the number of elements in the listcellIndexList
: if the latter contains exactly one cell index then the return value is the formatted tablelist element indicated by that cell index; otherwise the command returns the list of all of the formatted tablelist elements corresponding to the cell indices specified bycellIndexList
. pathName getformattedcolumns firstColumn lastColumn
pathName getformattedcolumns columnIndexList
- The first form of the command returns a list whose elements are
lists themselves, where each of the sublists corresponds to exactly
one column between
firstColumn
andlastColumn
, inclusive, and consists of all of the formatted tablelist elements contained in that column. The value returned by the second form depends on the number of elements in the listcolumnIndexList
: if the latter contains exactly one column index then the return value is a list consisting of all of the formatted tablelist elements contained in the column indicated by that column index; otherwise the command returns a list whose elements are lists themselves, where each of the sublists corresponds to exactly one column index incolumnIndexList
and consists of all of the formatted tablelist elements contained in that column. pathName getfullkeys first last
pathName getfullkeys indexList
- The first form of the command returns a list whose elements are
all of the full keys associated with the tablelist items between
first
andlast
, inclusive. The value returned by the second form depends on the number of elements in the listindexList
: if the latter contains exactly one index then the return value is the full key associated with the tablelist item indicated by that index (or an empty string if the index refers to a non-existent item); otherwise the command returns the list of all of the full keys associated with the tablelist items corresponding to the indices specified byindexList
. - Each item of a tablelist widget has a unique
sequence number that remains unchanged until the item is deleted,
thus acting as a key that uniquely identifies the item even if the
latter's position (i.e., numerical row index) changes. This
command provides read-only access to the full keys obtained by
prepending the letter
k
to these internal item IDs. pathName getkeys first last
pathName getkeys indexList
- The first form of the command returns a list whose elements are
all of the sequence numbers associated with the tablelist items
between
first
andlast
, inclusive. The value returned by the second form depends on the number of elements in the listindexList
: if the latter contains exactly one index then the return value is the sequence number associated with the tablelist item indicated by that index (or an empty string if the index refers to a non-existent item); otherwise the command returns the list of all of the sequence numbers associated with the tablelist items corresponding to the indices specified byindexList
. - Each item of a tablelist widget has a unique sequence number that remains unchanged until the item is deleted, thus acting as a key that uniquely identifies the item even if the latter's position (i.e., numerical row index) changes. This command provides read-only access to these internal item IDs.
pathName hasattrib name
- Returns
1
if the attributename
exists and0
otherwise. pathName hascellattrib cellIndex name
- Returns
1
if the attributename
for the cell given bycellIndex
exists and0
otherwise. pathName hascolumnattrib columnIndex name
- Returns
1
if the attributename
for the column given bycolumnIndex
exists and0
otherwise. pathName hasrowattrib index name
- Returns
1
if the attributename
for the row given byindex
exists and0
otherwise. pathName hidetargetmark
- Hides the horizontal gap or vertical bar displayed by the
showtargetmark
command. No error is generated if the target indicator is not visible at the time the command is invoked. - This command is designed to be used during a drag & drop operation for which the tablelist widget (or its body component) was registered as a drop target. See the DRAG & DROP SUPPORT section for details and examples.
pathName imagelabelpath cellIndex
- Returns the path name of the label widget containing the image
embedded into the cell given by
cellIndex
, as specified with the-image
option of thecellconfigure
subcommand. If no image is currently embedded into the cell then the return value is an empty string. - REMARK: This subcommand comes in handy
if you want to associate a binding script with the embedded
images. The recommended way to achieve this is shown in the
following example:
bind [.tbl bodytag] <Button-1> {printClickedImage %W %x %y}
proc printClickedImage {w x y} { foreach {tbl x y} [tablelist::convEventFields $w $x $y] {} set cellIdx [$tbl containingcell $x $y] scan $cellIdx "%d,%d" row col if {$row >= 0 && $col >= 0 && [string compare $w [$tbl imagelabelpath $cellIdx]] == 0} { puts "clicked the image of cell $cellIdx" } } pathName index index
- Returns the integer row index value that corresponds to
index
. For compatibility with the Tk core listbox, ifindex
isend
then the return value is the number of items in the tablelist (not the index of the last item). To get the numerical index of the last item, you can pass the wordlast
asindex
argument. pathName insert index ?item item ...?
- Inserts zero or more new items in the widget's internal list
just before the item given by
index
if the tablelist'sstate
is notdisabled
. Ifindex
equals the number of items or is specified asend
then the new items are added to the end of the widget's list. Tabulator characters are displayed as\t
(i.e., a backslash followed by at
) but are inserted unchanged into the internal list. Newline characters will force line breaks, i.e., will give rise to multi-line elements (which are displayed in embedded message widgets, created on demand). The return value is the list of full keys associated with the items just inserted. - REMARK: This subcommand is not suitable
for inserting items into a tablelist designed for displaying a tree
hierarchy. For such tablelist widgets use the
insertchildren
orinsertchildlist
subcommand. pathName insertchildlist parentNodeIndex childIndex itemList
- Inserts the items of the list
itemList
in the widget's internal list of children of the node specified byparentNodeIndex
just before the item given bychildIndex
if the tablelist'sstate
is notdisabled
.childIndex
must be a number,last
(specifying the parent's last child), orend
; if it equals the number of children of the node given byparentNodeIndex
or is specified asend
then the new items are added to the end of the parent's list of children. Tabulator characters are displayed as\t
(i.e., a backslash followed by at
) but are inserted unchanged into the internal list. Newline characters will force line breaks, i.e., will give rise to multi-line elements (which are displayed in embedded message widgets, created on demand). The return value is the list of full keys associated with the items just inserted. - This command has the same effect as
eval [list pathName insertchildren parentNodeIndex childIndex] itemList
- but it is more efficient and easier to use.
- For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this subcommand is not supported for Tk versions earlier than 8.3. - REMARK: You can achieve a quite
significant speadup by using this subcommand to insert a whole list
of items rather than using multiple invocations of
insertchildren
. pathName insertchildren parentNodeIndex childIndex ?item item ...?
- Inserts zero or more new items in the widget's internal list of
children of the node specified by
parentNodeIndex
just before the item given bychildIndex
if the tablelist'sstate
is notdisabled
.childIndex
must be a number,last
(specifying the parent's last child), orend
; if it equals the number of children of the node given byparentNodeIndex
or is specified asend
then the new items are added to the end of the parent's list of children. Tabulator characters are displayed as\t
(i.e., a backslash followed by at
) but are inserted unchanged into the internal list. Newline characters will force line breaks, i.e., will give rise to multi-line elements (which are displayed in embedded message widgets, created on demand). The return value is the list of full keys associated with the items just inserted. - For technical reasons (the use of the
-elide
text widget tag option for collapsing a row), this subcommand is not supported for Tk versions earlier than 8.3. - REMARK: It is explicitly allowed to
abbreviate the name
insertchildren
asinsertchild
. This comes in handy when using this subcommand to insert just one child item. pathName insertcolumnlist columnIndex columnList
- Inserts the columns specified by the list
columnList
just before the column given bycolumnIndex
if the tablelist'sstate
is notdisabled
. IfcolumnIndex
equals the number of columns or is specified asend
then the new columns are added to the end of the column list. The argumentcolumnList
must be a list containing the width, title, and optional alignment specifications for the new columns, in the same form as in the case of the-columns
configuration option. The return value is an empty string. The elements of the new columns are initially empty strings; the easiest way to change these values is to use thefillcolumn
subcommand or the-text
column configuration option. - This command has the same effect as
eval [list pathName insertcolumns columnIndex] columnList
- but it is more efficient and easier to use.
pathName insertcolumns columnIndex ?width title ?alignment? width title ?alignment? ...?
- Inserts zero or more new columns just before the column given
by
columnIndex
if the tablelist'sstate
is notdisabled
. IfcolumnIndex
equals the number of columns or is specified asend
then the new columns are added to the end of the column list. The arguments following the column index have the same meanings as in the case of the-columns
configuration option. The return value is an empty string. The elements of the new columns are initially empty strings; the easiest way to change these values is to use thefillcolumn
subcommand or the-text
column configuration option. pathName insertlist index itemList
- Inserts the items of the list
itemList
in the widget's internal list just before the item given byindex
if the tablelist'sstate
is notdisabled
. Ifindex
equals the number of items or is specified asend
then the new items are added to the end of the widget's list. Tabulator characters are displayed as\t
(i.e., a backslash followed by at
) but are inserted unchanged into the internal list. Newline characters will force line breaks, i.e., will give rise to multi-line elements (which are displayed in embedded message widgets, created on demand). The return value is the list of full keys associated with the items just inserted. - This command has the same effect as
eval [list pathName insert index] itemList
- but it is more efficient and easier to use.
- REMARK 1: You can achieve a quite
significant speadup by using this subcommand to insert a whole list
of items rather than using multiple invocations of
insert
. - REMARK 2: This subcommand is not
suitable for inserting items into a tablelist designed for
displaying a tree hierarchy. For such tablelist widgets use
the
insertchildlist
orinsertchildren
subcommand. pathName iselemsnipped cellIndex fullTextName
- Returns the value
1
if the text displayed in the cell specified bycellIndex
is snipped and0
otherwise. In both cases, the full (unsnipped) cell text is stored in the variable having the name given byfullTextName
; this full text can be the cell's contents or the string obtained from the latter by using the-formatcommand
option of the cell's column. The most common invocation of this command occurs within the procedure specified as the value of the-tooltipaddcommand
configuration option. pathName isexpanded index
- Returns the value
1
if the row indicated byindex
is expanded and0
otherwise. pathName istitlesnipped columnIndex fullTextName
- Returns the value
1
if the text displayed in the header label specified bycolumnIndex
is snipped and0
otherwise. In both cases, the full (unsnipped) label text is stored in the variable having the name given byfullTextName
. The most common invocation of this command occurs within the procedure specified as the value of the-tooltipaddcommand
configuration option. pathName isviewable index
- Returns the value
1
if the row indicated byindex
is viewable and0
otherwise. A tablelist row is called viewable if the value of its-hide
option is false and all its ancestors are (partly) expanded. Likewise, a tablelist cell is called viewable if its row is viewable and the value of its column's-hide
option is false. pathName itemlistvar
- Returns the name of a variable used by Tablelist to hold the
widget's internal list. The recommended way to use this
variable is to create a link to it with the aid of the
upvar
command, like in the following example:upvar #0 [.tbl itemlistvar] itemList
- In this example, the value of the variable
itemList
will be the internal list of the tablelist widget.tbl
. Each element of the widget's internal list corresponds to one item, and it is in turn a list whose elements correspond to the elements of that item, except that it has one additional element, holding the item's full key. - REMARK: The
itemlistvar
command provides an efficient way for accessing this internal list, instead of retrieving the items with theget
subcommand or using the-listvariable
option (these methods consume significantly more memory). It can be useful in situations where the elements of a tablelist widget are to be accessed for creating text files, HTML output, XML data, database commands, etc. This should, however, be a strictly readonly access; otherwise the results will be unpredictable! pathName labelpath columnIndex
- Returns the path name of the header label corresponding to the
column indicated by
columnIndex
. pathName labels
- Returns a list containing the path names of all header labels of the widget.
pathName labeltag
- Returns the name of a binding tag whose name depends on the
path name of the tablelist widget and which is associated with the
header labels as well as with the additional widgets placed by
Tablelist into the latters for displaying header images and sort
arrows. This binding tag is designed to be used when defining
non-default binding scripts for the header labels. From
within such event handling scripts you can retrieve the column
number and the tablelist widget's path name with the aid of the
helper commands
tablelist::getTablelistColumn
andtablelist::getTablelistPath
. pathName move sourceIndex targetIndex
pathName move sourceIndex targetParentNodeIndex targetChildIndex
- The first form of the command moves the item indicated by
sourceIndex
just before the one given bytargetIndex
if the tablelist'sstate
is notdisabled
. IftargetIndex
equals the nunber of items or is specified asend
then the source item is moved after the last one. The item specified bytargetIndex
must have the same parent as the one given bysourceIndex
, or else it must be the item just below the last descendant of the source node's parent. - The command's second form moves the item indicated
by
sourceIndex
just before the node having the parent indicated bytargetParentNodeIndex
and the indextargetChildIndex
in the parent's list of children if the tablelist'sstate
is notdisabled
.targetChildIndex
must be a number,last
(specifying the target parent's last child), orend
; if it equals the number of children of the target parent node or is specified asend
then the source item is moved after the target parent node's last child. - Both forms of the command preserve the node hierarchy under the source item, by moving its descendants accordingly. The return value is an empty string.
pathName movecolumn sourceColumn targetColumn
- Moves the column indicated by
sourceColumn
just before the one given bytargetColumn
if the tablelist'sstate
is notdisabled
. IftargetColumn
equals the number of columns or is specified asend
then the source column is moved after the last one. Returns an empty string. pathName nearest y
- Given a y-coordinate within the tablelist window, this command
returns the index of the viewable
tablelist item nearest to that y-coordinate. The coordinate
y
is expected to be relative to the tablelist window itself (not its body component). pathName nearestcell x y
- Given an x- and a y-coordinate within the tablelist window,
this command returns the index of the viewable tablelist cell nearest to the point
having these coordinates. The coordinates
x
andy
are expected to be relative to the tablelist window itself (not its body component). pathName nearestcolumn x
- Given an x-coordinate within the tablelist window, this command
returns the index of the non-hidden tablelist column nearest to
that x-coordinate. The coordinate
x
is expected to be relative to the tablelist window itself (not its body component). pathName noderow parentNodeIndex childIndex
- Returns the numerical row index of the node having the parent
indicated by
parentNodeIndex
and the indexchildIndex
in the parent's list of children.childIndex
must be a number,last
(specifying the parent's last child), orend
; if it equals the number of children of the parent node or is specified asend
then the return value will be the row index of the item following the parent node's last descendant. pathName parentkey nodeIndex
- Returns the full key of the parent of the tree node indicated
by
nodeIndex
. If this argument is specified asroot
then the return value will be an empty string. IfnodeIndex
identifies a top-level item then the subcommand will returnroot
. For all other items the return value will be a full key of the formknumber
. pathName refreshsorting ?parentNodeIndex?
- Sorts the children of the tablelist node specified by
parentNodeIndex
according to the parameters of the most recentsort
,sortbycolumn
, orsortbycolumnlist
invocation. If the items haven't been sorted at all, or the sort information was reset by invokingresetsortinfo
, then no sorting takes place. The optional argumentparentNodeIndex
defaults toroot
, meaning that all the items are to be sorted per default. The return value is an empty string. pathName rejectinput
- If invoked from within the Tcl command specified by the
-editendcommand
configuration option, then this subcommand prevents the termination of the interactive editing of the contents of the cell whose index was passed to theeditcell
subcommand. It invokes theseecell
subcommand to make sure the respective cell becomes visible (in case it was scrolled out of view), and sets the focus to the temporary widget embedded into the cell. This command enables you to reject the widget's text during the final validation of the string intended to become the new cell contents. The return value is an empty string. pathName resetsortinfo
- Resets the information about the sorting of the items.
Subsequent invocations of
sortcolumn
andsortorder
will return-1
and an empty string, respectively. Similarly, subsequent invocations ofsortcolumnlist
andsortorderlist
will return an empty string. This command also removes any existing up- or down-arrows displayed by an earlier invocation ofsortbycolumn
orsortbycolumnlist
. The return value is an empty string. pathName rowattrib index ?name? ?value name value ...?
- Queries or modifies the attributes of the row given by
index
. If noname
is specified, the command returns a list of pairs, each of which contains the name and the value of an attribute for the row. Ifname
is specified with novalue
, then the command returns the value of the one named row attribute, or an empty string if no corresponding value exists (you can use thehasrowattrib
subcommand to distinguish this case from the one that the value of an existing row attribute is an empty string). If one or morename
-value
pairs are specified, then the command sets the given row attribute(s) to the given value(s); in this case the return value is an empty string.name
may be an arbitrary string. pathName rowcget index option
- Returns the current value of the row configuration option given
by
option
for the row specified byindex
.option
may have any of the values accepted by therowconfigure
command. pathName rowconfigure index ?option? ?value option value ...?
- Queries or modifies the configuration options of the row given
by
index
. If nooption
is specified, the command returns a list describing all of the available options for the row (seeTk_ConfigureInfo
for information on the format of this list). Ifoption
is specified with novalue
, 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 nooption
is specified). If one or moreoption
-value
pairs are specified, then the command modifies the given row option(s) to have the given value(s); in this case the return value is an empty string.option
may have any of the values described in the ROW CONFIGURATION OPTIONS section. pathName scan option args
- This command is used to implement scanning on tablelist
widgets. It has two forms, depending on
option
: -
pathName scan mark x y
- Records
x
andy
and the current view in the tablelist window; used in conjunction with laterscan dragto
commands. Typically this command is associated with a mouse button press in the body component of the widget. It returns an empty string. The coordinatesx
andy
are expected to be relative to the tablelist window itself (not its body component). pathName scan dragto x y
- This command computes the difference between its
x
andy
arguments to the lastscan mark
command for the widget. It then adjusts the view (the vertical one only in the body component) by 10 times the difference in coordinates. This command is typically associated with mouse motion events in the body component of the widget, to produce the effect of dragging the table at high speed through the window. The return value is an empty string. The coordinatesx
andy
are expected to be relative to the tablelist window itself (not its body component).
pathName searchcolumn columnIndex pattern ?options?
- This subcommand searches the elements of the column given by
columnIndex
to see if one of them matchespattern
. If a match is found, the row index of the first matching element is returned as result (unless the option-all
is specified). If not, the return value is-1
. One or more of the following options may be specified to control the search: -
-all
Changes the result to be the list of all matching row indices, which will be in numeric order (or in reverse numeric order when used with the -backwards
option).-backwards
The search will proceed backward through the given column's elements. -check command
Specifies an additional condition to be fulfilled by the matching elements. If an element of the specified column matches the given pattern and command is a nonempty string, then the latter is automatically concatenated with the name of the tablelist widget, the element's row index, the numerical equivalent of columnIndex
, as well as the element itself or its formatted version (depending on the presence of the-formatted
option), the resulting script is evaluated in the global scope, and the return value (which must be a boolean) will determine whether the element in question will still be viewed as matching or not. The default command is an empty string. This option enables you to pass arbitrary additional matching criteria to the searching process.-descend
Search the elements of the specified column in all descendants of the tree node given by the -parent
option. The elements will be visited in the order of their row indices (or in reverse order of their row indices when used with the-backwards
option). The default is to restrict the search to the parent node's children only.-exact
The matching element(s) must be identical to the literal string pattern
.-formatted
Examine the formatted versions of the elements rather than the internal cell values. -glob
Treat pattern
as a glob-style pattern and match it against the elements using the same rules as thestring match
command.-nocase
Causes comparisons to be handled in a case-insensitive manner. Has no effect if combined with the -numeric
option.-not
This option negates the sense of the match, returning the row index of the first non-matching element (or, in the presence of the -all
option, the list of row indices of all non-matching elements) of the given column.-numeric
The elements are to be compared to pattern
as integer or floating-point values, using the==
comparison operator. This option is only meaningful when used with-exact
.-parent nodeIndex
This option restricts the search to the children (or descendants, when used with -descend
) of the tree node given bynodeIndex
. The default parent isroot
.-regexp
Treat pattern
as a regular expression and match it against the elements using the rules described in there_syntax
reference page.-start index
The elements of the specified column are to be searched (forwards or backwards) starting at the row given by index
. This option makes it easy to provide incremental search. - If all matching style options
-exact
,-glob
, and-regexp
are omitted then the matching style defaults to-glob
. If more than one of them is specified, the last matching style given takes precedence. - Before examining the children (or descendants, when
used with the
-descend
option) of a row whose children have not been inserted yet, the command specified as the value of the-populatecommand
option (if any) is automatically concatenated with the name of the tablelist widget and the row index, and the resulting script is evaluated in the global scope. This enables you to insert the children on demand, just before searching them for the specified pattern. pathName see index
- Adjusts the view in the tablelist so that the item given by
index
is visible. If the item is already visible then the command has no effect; if the item is near one edge of the window then the tablelist scrolls to bring the item into view at the edge; otherwise the tablelist scrolls to center the item. pathName seecell cellIndex
- Adjusts the view in the tablelist so that the cell given by
cellIndex
is visible. If the cell is already visible then the command has no effect; if the cell is near one edge of the window then the tablelist scrolls to bring the cell into view at the edge; otherwise the tablelist scrolls to center the cell. If the value of the-titlecolumns
option is positive then the centering of the cell is only done vertically; the horizontal scrolling (which in this case is performed column-wise) will just bring the cell into view next to the title columns or at the right edge of the window. - id="seecolumn">
pathName seecolumn columnIndex
- Adjusts the view in the tablelist so that the column given by
columnIndex
is visible. If the column is already visible then the command has no effect; if the column is near one edge of the window then the tablelist scrolls horizontally to bring the column into view at the edge; otherwise the tablelist scrolls horizontally to center the column. If the value of the-titlecolumns
option is positive then the horizontal scrolling (which in this case is performed column-wise) will just bring the column into view next to the title columns or at the right edge of the window. pathName selection option args
- This command is used to adjust the selection within a tablelist
widget. It has several forms, depending on
option
: -
pathName selection anchor index
- Sets the selection anchor to the item given by
index
. Ifindex
refers to a nonexistent or non-viewable item, then the closest viewable item is used. The selection anchor is the end of the selection that is fixed while dragging out a selection with the mouse if the selection type isrow
. The indexanchor
may be used to refer to the anchor item. pathName selection clear first last
pathName selection clear indexList
- If any of the items between
first
andlast
(inclusive) or corresponding to the indices specified by the listindexList
contain at least one selected cell, they are deselected. The selection state is not changed for items outside the range given in the first form of the command or different from those specified by the index list given in its second form. pathName selection includes index
- Returns
1
if the item indicated byindex
contains at least one selected cell,0
if it doesn't. pathName selection set first last
pathName selection set indexList
- Selects all of the selectable items in the range between
first
andlast
, inclusive, or corresponding to the indices specified by the listindexList
, without affecting the selection state of any other items.
- If the tablelist's
state
isdisabled
andoption
is different fromincludes
then the command just returns an empty string, without performing any of the above actions. pathName separatorpath ?columnIndex?
- If the optional argument is not specified, then this command
returns the path name of the special separator displayed to mark
the end of the title columns if the value of the
-titlecolumns
option is positive and an empty string otherwise. If the optional argument is present, then the command returns the path name of the separator attached to the right edge of the header label indicated bycolumnIndex
if the value of the-showseparators
configuration option is true and an empty string otherwise. pathName separators
- Returns a list containing the path names of all column
separators. If the value of the
-titlecolumns
option is positive then the first element of the list will be the path name of the special separator displayed to mark the end of the title columns. Whether the path names of the other separators are included in the list, depends on the value of the-showseparators
configuration option. pathName showtargetmark before|inside index
- Displays a drop target indicator having the form of a
horizontal gap or vertical bar before or inside the row specified
by
index
. If the subcommand's name is followed bybefore
andindex
equals the number of items or is specified asend
then the horizontal gap will be shown just after the tablelist's last row. If the subcommand is used with theinside
option then the indexend
is interpreted as indicating the widget's last item. - This command is designed to be used during a drag & drop operation for which the tablelist widget (or its body component) was registered as a drop target. See the DRAG & DROP SUPPORT section for details and examples.
pathName size
- Returns the total number of items in the tablelist widget.
pathName sort ?-increasing|-decreasing?
- Sorts the items in increasing or decreasing order, as specified
by the optional argument. The default is
-increasing
. Uses the value of the-sortcommand
widget configuration option as comparison command.sort
also removes any existing up- or down-arrows displayed by an earlier invocation ofsortbycolumn
orsortbycolumnlist
. After sorting the items, the command conditionally adjusts the vertical view as follows: (a) if interactive cell editing is in progress then the cell being edited is brought into view; (b) else, if exactly one item is selected then the view is shifted to bring that item into view; (c) else, if the tablelist's body is the most recent window to have the input focus among all the windows in the same top-level as the widget itself then the currently active item is brought into view. pathName sortbycolumn columnIndex ?-increasing|-decreasing?
- Sorts the items based on the elements of the column given by
columnIndex
, in increasing or decreasing order, as specified by the optional argument. The default is-increasing
. The sorting process is controlled by the values of the-sortmode
and-sortcommand
options for the given column. If both the value of the-showarrow
configuration option and that of the-showarrow
option for the specified column are true then an up- or down-arrow indicating the sort order will be placed into the column's label. The shape of the arrow depends on the command's optional argument and on the value of the-incrarrowtype
configuration option. If the label's text is right-aligned then the arrow will be displayed on the left side of the label, otherwise on its right side. After sorting the items, the vertical view is adjusted in the same way as in the case of thesort
subcommand. - The actions described above are only performed if
the specified column's
-showlinenumbers
option hasn't been set to true. pathName sortbycolumnlist columnIndexList ?sortOrderList?
- Sorts the items based on the elements of the columns given by
the
columnIndexList
argument, which must be a list of distinct column indices. Only those elements of this list are considered significant that identify columns whose-showlinenumbers
option hasn't been set to true. - The items are first sorted based on the column
specified by the last significant element of
columnIndexList
, then based on the one given by the last but one significant element, and so on. The order of each sort operation is taken from the optional argumentsortOrderList
, whose elements must be (abbreviations of)increasing
ordecreasing
. If this argument was not specified or contains less elements thancolumnIndexList
then the missing sort orders are assumed to beincreasing
. Each sorting process is controlled by the values of the-sortmode
and-sortcommand
options for the respective column. If the column's index was specified among the first 9 significant elements ofcolumnIndexList
and both the value of the-showarrow
configuration option and that of the-showarrow
option for that column are true then an up- or down-arrow indicating the sort order will be placed into the column's label. The shape of the arrow depends on the respective sort order and on the value of the-incrarrowtype
configuration option. If the label's text is right-aligned then the arrow will be displayed on the left side of the label, otherwise on its right side. If more than one sort arrows are to be displayed then the first 9 sort ranks (1
for the first significant element ofcolumnIndexList
,2
for the second one, and so on) will also be shown to the right of the arrows. After sorting the items, the vertical view is adjusted in the same way as in the case of thesort
subcommand. pathName sortcolumn
- Returns the numerical index of the column by which the items
were last sorted with the aid of the
sortbycolumn
orsortbycolumnlist
command, or-1
if they were last sorted with thesort
command or haven't been sorted at all, or the sort information was reset by invokingresetsortinfo
. If called from within the command specified as the value of the-sortcommand
widget or column configuration option, then the return value of this subcommand refers to the sorting in progress rather than the most recent one. pathName sortcolumnlist
- Returns a list consisting of the numerical indices of the
columns by which the items were last sorted with the aid of the
sortbycolumnlist
orsortbycolumn
command (in the second case the list will contain exactly one element), or an empty string if they were last sorted with thesort
command or haven't been sorted at all, or the sort information was reset by invokingresetsortinfo
. If called from within the command specified as the value of the-sortcommand
widget or column configuration option, then the return value of this subcommand refers to the sorting in progress rather than the most recent one. pathName sortorder
- Returns the sort order (as
increasing
ordecreasing
) from the last sorting performed by thesort
,sortbycolumn
, orsortbycolumnlist
command, or an empty string if the items haven't been sorted at all, or the sort information was reset by invokingresetsortinfo
. If called from within the command specified as the value of the-sortcommand
widget or column configuration option, then the return value of this subcommand refers to the sorting in progress rather than the most recent one. pathName sortorderlist
- Returns a list consisting of the sort orders (as
increasing
ordecreasing
) from the last invocation of thesortbycolumnlist
orsortbycolumn
command (in the second case the list will contain exactly one element), or an empty string if the items were last sorted with thesort
command or haven't been sorted at all, or the sort information was reset by invokingresetsortinfo
. If called from within the command specified as the value of the-sortcommand
widget or column configuration option, then the return value of this subcommand refers to the sorting in progress rather than the most recent one. pathName targetmarkpath
- Returns the path name of the drop target indicator (displayed as a horizontal gap or vertical bar) belonging to the tablelist's body.
pathName targetmarkpos y ?-any|-horizontal|-vertical?
- Given a y-coordinate within the tablelist window, this command
returns a two-element list containing the arguments to be passed to
the
showtargetmark
subcommand in order to display the drop target indicator corresponding to that y-coordinate. The first list element will be the stringbefore
orinside
, and the second one a numerical row index. These list elements depend on the relative position ofy
within the containing row (if any), as well as on the optional second argument: The default option-any
allows bothbefore
andinside
as first element of the result list, while the options-horizontal
and-vertical
restrict the value of the first list element tobefore
andinside
, respectively. If the option-vertical
was specified and no tablelist item contains the given y-position, then the return value is the list{inside -1}
. The coordinatey
is expected to be relative to the tablelist window itself (not its body component). - This command is designed to be used during a drag & drop operation for which the tablelist widget (or its body component) was registered as a drop target. See the DRAG & DROP SUPPORT section for details and examples.
pathName togglecolumnhide firstColumn lastColumn
pathName togglecolumnhide columnIndexList
- Toggles the value of the
-hide
option for one or more columns of the tablelist widget. In the first form of the command,firstColumn
andlastColumn
are indices specifying the first and last columns in the range whose visibility is to be toggled. The command's second form accepts a listcolumnIndexList
of indices specifying the columns whose visibility is to be toggled. Returns an empty string. After toggling the hidden state of the specified columns, the<<TablelistColHiddenStateChanged>>
virtual event is generated. For Tk versions 8.5 or higher, this virtual event is generated with its-data
option set to a list consisting of the numerical column indices of the columns whose-hide
option was toggled. The main advantage of using this command instead of invokingcolumnconfigure
for each of the specified columns is that it causes only one redisplay of the widget's contents, thus being significantly faster. pathName togglerowhide first last
pathName togglerowhide indexList
- Toggles the value of the
-hide
option for one or more rows of the tablelist widget. In the first form of the command,first
andlast
are indices specifying the first and last rows in the range whose visibility is to be toggled. The command's second form accepts a listindexList
of indices specifying the rows whose visibility is to be toggled. Returns an empty string. After toggling the hidden state of the specified rows, the<<TablelistRowHiddenStateChanged>>
virtual event is generated. For Tk versions 8.5 or higher, this virtual event is generated with its-data
option set to a list consisting of the numerical row indices of the rows whose-hide
option was toggled. Just like the-hide
row configuration option, this subcommand is not supported for Tk versions earlier than 8.3. - CAUTION: Tk versions 8.3 - 8.4.12 had a bug that caused a segmentation fault if the whole content of a text widget was elided. This bug was also present in Tk 8.5.a1 - 8.5.a3. When using one of these earlier Tk versions, this bug will produce a crash if all the rows of a tablelist widget are hidden. It is your responsibility to avoid such situations when using a Tk version having this bug!
pathName toplevelkey index
- If the item identified by
index
is a top-level one then the subcommand returns the full key of that item. Otherwise the return value is the full key of the unique top-level item having the given item among its descendants. pathName unsetattrib name
- Unsets the attribute
name
. Returns an empty string. pathName unsetcellattrib cellIndex name
- Unsets the attribute
name
for the cell given bycellIndex
. Returns an empty string. pathName unsetcolumnattrib columnIndex name
- Unsets the attribute
name
for the column given bycolumnIndex
. Returns an empty string. pathName unsetrowattrib index name
- Unsets the attribute
name
for the row given byindex
. Returns an empty string. pathName viewablerowcount ?first last?
- Returns the number of viewable rows
in the index range given by
first
andlast
. If these optional indices are not specified thenfirst
defaults to0
andlast
defaults to one less the total number of items, i.e., the index range comprises all rows. pathName windowpath cellIndex
- Returns the path name of the window contained in the cell given
by
cellIndex
, created with the-window
option of thecellconfigure
subcommand. If no window is currently embedded into the cell then the return value is an empty string. pathName xview args
- This command is used to query and change the horizontal position of the information in the widget'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
and1
; 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 tablelist's scrollable text is off-screen to the left, the middle 40% is visible in the window, and 40% of the scrollable text is off-screen to the right. These are the same values passed to scrollbars via the-xscrollcommand
option. pathName xview units
- If the value of the
-titlecolumns
option is positive then this command adjusts the view in the window so that the column whose offset from the end of the title column area equalsunits
non-hidden columns is displayed next to the title columns. Otherwise the command adjusts the view in the window so that the character position given byunits
is displayed at the left edge of the window. Character positions are defined by the width of the character0
. pathName xview moveto fraction
- Adjusts the view in the window so that
fraction
of the total width of the scrollable tablelist text is off-screen to the left.fraction
must be a fraction between0
and1
. pathName xview scroll number what
- This command shifts the view in the window left or right
according to
number
andwhat
.number
must be an integer.what
must be eitherunits
orpages
or an abbreviation of one of these. Ifwhat
isunits
, the view adjusts left or right bynumber
non-hidden columns or character units (the width of the0
character) on the display, depending on the value of the-titlecolumns
option; ifwhat
ispages
then the view adjusts bynumber
screenfuls. Ifnumber
is negative then columns or characters farther to the left become visible; if it is positive then columns or characters farther to the right become visible.
pathName yview args
- This command is used to query and change the vertical position of the text in the window of the widget's body component. It can take any of the following forms:
-
pathName yview
- Returns a list containing two elements, both of which are real
fractions between
0
and1
. The first element gives the position of the viewable tablelist item at the top of the window, relative to the tablelist as a whole (0.5
means it is halfway through the tablelist, for example). The second element gives the position of the viewable tablelist item just after the last one in the window, relative to the tablelist as a whole. These are the same values passed to scrollbars via the-yscrollcommand
option. pathName yview units
- Adjusts the view in the window so that the item whose offset
equals
units
viewable rows is displayed at the top of the window. pathName yview moveto fraction
- Adjusts the view in the window so that the viewable item given by
fraction
appears at the top of the window.fraction
is a fraction between0
and1
;0
indicates the first viewable item in the tablelist,0.33
indicates the viewable item one-third the way through the tablelist, and so on. pathName yview scroll number what
- This command shifts the view in the window up or down according
to
number
andwhat
.number
must be an integer.what
must be eitherunits
orpages
or an abbreviation of one of these. Ifwhat
isunits
, the view adjusts up or down bynumber
viewable rows; if it ispages
then the view adjusts bynumber
screenfuls. Ifnumber
is negative then earlier items become visible; if it is positive then later items become visible.
- DEFAULT AND INDIVIDUAL BINDINGS FOR THE TABLELIST BODY
- The body component of a tablelist is implemented as a text
widget whose binding tag
Text
is replaced with a new binding tag calledTablelistBody
. The latter has all the events of theListbox
widget class, and several of its binding scripts are obtained from those ofListbox
by replacing the event fields%W
,%x
, and%y
with the path name of the tablelist widget and the x and y coordinates relative to the latter. These values are assigned to the help variablestablelist::W
,tablelist::x
, andtablelist::y
by invoking the helper commandtablelist::convEventFields
as follows:foreach {tablelist::W tablelist::x tablelist::y} \ [tablelist::convEventFields %W %x %y] {}
- This conversion of the event fields is necessary because the
Tcl command associated with a tablelist expects any coordinates
relative to the widget itself, not its body component. It
makes use of help variables from the
tablelist
namespace in order to avoid any conflicts with global variables. - Several of the events have no
%x
and%y
fields; in this case another helper commandtablelist::getTablelistPath
is used to set the help variabletablelist::W
to the path name of the tablelist widget:set tablelist::W [tablelist::getTablelistPath %W]
- The binding tag
TablelistBody
replaces the class name (Frame
orTSeparator
) of the separator widgets, too. It also replaces the binding tagMessage
of the message widgets used to display multi-line elements, as well as the binding tagLabel
of the label widgets used to display embedded images. This makes sure that the default handling of the mouse events on the column separators, multi-line cells, and embedded images is the same as in the rest of the tablelist's body. - When defining individual bindings for tablelist
widgets, the same conversion of the event fields is needed as for
the default bindings. For example, the binding script below
for the tablelist widget
.tbl
prints the index of the cell where mouse button 1 was clicked:bind [.tbl bodytag] <Button-1> { foreach {tablelist::W tablelist::x tablelist::y} \ [tablelist::convEventFields %W %x %y] {} puts "clicked on cell [.tbl containingcell $tablelist::x $tablelist::y]" }
- By associating the script with the binding tag returned by the
bodytag
subcommand instead of just with the path name of the tablelist's body we make sure to have the same event handling for the separators, multi-line cells, and embedded images as for the rest of the tablelist's body. - The following improved version of the binding script
above uses a procedure and thus eliminates the need for prefixing
the converted variables with
"tablelist::"
:bind [.tbl bodytag] <Button-1> {printClickedCell %W %x %y}
proc printClickedCell {w x y} { foreach {tbl x y} [tablelist::convEventFields $w $x $y] {} puts "clicked on cell [$tbl containingcell $x $y]" } - The bindings associated with the binding tag
TablelistBody
, created automatically by thetablelist::tablelist
command, ensure that the body component of a tablelist has the same default behavior as a listbox widget. If the selection type isrow
(which is the default) then everything described in the "DEFAULT BINDINGS" section of the listbox manual entry applies to the body component of a tablelist, too. The only difference is that the word "element" in that manual page has to be replaced with "item" when applying the description to the body of a tablelist widget. - If the selection type is
cell
then everything described in the "DEFAULT BINDINGS" section of the listbox manual entry applies to the body component of a tablelist, too, with the following extensions and changes: -
- If
Tab
orShift-Tab
is pressed, the location cursor (active element) moves to the next/previous element. If the selection mode isbrowse
orextended
then the new active element is also selected and all other elements are deselected. Inextended
mode the new active element becomes the selection anchor. Notice that these bindings replace the common inter-widget navigation viaTab
andShift-Tab
with inter-cell navigation. Just like in the case of the text widget,Control-Tab
andControl-Shift-Tab
are intended to be used for widget-to-widget keyboard navigation. Unfortunately, this won't always work because some window managers intercept the latter key sequences and use them for their own purposes (like inter-workplace navigation). For this reason, Tablelist supports the additional key sequencesMeta-Tab
andMeta-Shift-Tab
as replacements forControl-Tab
andControl-Shift-Tab
, respectively. - If the
Left
orRight
key is pressed, the location cursor (active element) moves to the previous/next element of the active row. If the selection mode isbrowse
orextended
then the new active element is also selected and all other elements are deselected. Inextended
mode the new active element becomes the selection anchor. - In
extended
mode,Shift-Left
andShift-Right
move the location cursor (active element) to the previous/next element of the active row and also extend the selection to that element in a fashion similar to dragging with mouse button 1. - If the
Home
orEnd
key is pressed, the location cursor (active element) moves to the first/last element of the active row, the new active element is selected, and all other elements are deselected. - In
extended
mode,Shift-Home
andShift-End
extend the selection to the first/last element of the active row. Inmultiple
mode,Shift-Home
andShift-End
move the location cursor to the first/last element of the active row. - If the location cursor is in an editable cell then
Return
andKP_Enter
start the interactive editing of the active element.
- If
- Just like in the case of the listbox widget, any
changes to the selection will automatically generate the virtual
event
<<ListboxSelect>>
. Instead of this event (which is supported for compatibility reasons), the virtual event<<TablelistSelect>>
can be used to be made aware of any changes to tablelist selection. Both events will be generated independently of the selection type. - LOCAL DRAG &
DROP: The following binding associated with the binding
tag
TablelistBody
is only valid if the selection mode issingle
ormultiple
:If mouse button 1 is clicked on an item and then dragged outside that item, and the value of the
-movablerows
configuration option is true, then the mouse cursor takes on the shape specified by the-movecursor
option, indicating that the item in question is being moved to another position. The new item position (if any) is visualized with the aid of a gap placed before the target row or a bar placed inside the latter (depending on the current mouse position), indicating whether the source item would be moved before this row or become a child of it. This local drag & drop operation ends when mouse button 1 is released, and can be canceled by pressing theEscape
key. In both cases, the mouse cursor is reset to its original value, specified by the-cursor
configuration option. After releasing mouse button 1 in the presence of a valid target, the source item is moved before the target row or just before the latter's first child, and the virtual event<<TablelistRowMoved>>
is generated. For Tk versions 8.5 or higher, this virtual event is generated with its-data
option set to a list of length 3, whose elements are derived from the arguments passed to the second form of themove
subcommand invoked for moving the source row to its new position. The first list element will be the full key corresponding to the first argument, the second one will beroot
or the full key corresponding to the second argument, and the third list element will be identical to the third argument passed to themove
subcommand.Notice that, depending on the current mouse position during the local drag & drop, there can be a corresponding potential target row or not. For instance, a tree item cannot become a sibling of one of its descendants, and not all items might be allowed to have children or to become top-level ones (example: in a file manager, regular file items cannot be parents of other items and should not be allowed to become top-level ones). To decide whether the row corresponding to the y-coordinate of the current mouse position represents a valid potential target, the Tablelist code first checks whether moving the source item before that row or making it a child of the latter is allowed from the point of view of the general tree structure. If this is the case and the move operation would change the source item's parent (and the Tk version is at least 8.3), and the command specified as the value of the
-acceptchildcommand
configuration option is a nonempty string, then this command is concatenated with the name of the tablelist widget, the node index of the would-be new parent node, and the row index of the dragged item, the resulting script is evaluated in the global scope, and if the return value (which must be a boolean) is false, then the source item will not be allowed to be moved to the current mouse position. Likewise, if the command specified as the value of the-acceptdropcommand
configuration option is a nonempty string, then this command is concatenated with the name of the tablelist widget, the row index of the would-be new target row, and the row index of the dragged item, the resulting script is evaluated in the global scope, and if the return value (which must be a boolean) is false, then the source item will not be allowed to be moved to the current mouse position.Recall that if the selection mode is
multiple
then pressing mouse button 1 on a selected item or element normally deselects that item or element (depending on the selection type). However, if in addition the value of the-movablerows
configuration option is true then the clicked row is a potential drag source for the local drag & drop operation described above, and for this reason the clicked item or element will only be deselected when releasing mouse button 1 over the same item or element. - DRAG SOURCE SUPPORT FOR
GLOBAL DRAG & DROP: Besides the local drag &
drop, the default bindings also support the TkDND compiled
extension and the drag & drop framework included in BWidget, as
well as custom drag & drop implementations. A tablelist
widget is viewed as a drag source for mouse button 1 if its
body component was registered as such via the
tkdnd::drag_source register
or the WidgetDragSite::register
command, or the tablelist's-customdragsource
option was set to true. The default bindings provide drag source support as described below: -
- If the selection mode is
extended
then pressing mouse button 1 on a selected item or element normally deselects all the other items or elements (depending on the selection type). However, if the tablelist is a drag source for mouse button 1, then the other items or elements will only be deselected when releasing mouse button 1 over the clicked item or element. This is because the mouse click might be followed by a drag, intended for all currently selected items or elements. - Similarly, if the selection mode is
multiple
then pressing mouse button 1 on a selected item or element normally deselects that item or element (depending on the selection type). However, if the tablelist is a drag source for mouse button 1, then the clicked item or element will only be deselected when releasing mouse button 1 over the same item or element. Again, this is because the mouse click might be followed by a drag, intended for all currently selected items or elements. - Whenever the mouse leaves the tablelist window with button 1 down. the default bindings normally perform an automatic scrolling, just like in the case of the Tk listbox widget. However, if the tablelist is a drag source for mouse button 1, then the automatic scrolling will be suppressed, in order to avoid any conflicts with the drag operation.
- If the selection mode is
- TREE WIDGET BINDINGS: The following
bindings associated with the binding tag
TablelistBody
apply to tablelists used as tree widgets: -
- Pressing mouse button 1 over an expand/collapse control toggles the expanded/collapsed state of the corresponding row.
- If the current active row contains an
expand/collapse control in collapsed state then the
Right
,plus
, andKP_Add
keys expand the corresponding row by invoking the non-recursive version of theexpand
subcommand. - If the current active row contains an
expand/collapse control in expanded state then the
Left
,minus
, andKP_Subtract
keys collapse the corresponding row by invoking the non-recursive version of thecollapse
subcommand.
- DEFAULT AND INDIVIDUAL BINDINGS FOR THE HEADER LABELS
- The
tablelist::tablelist
command automatically creates the following bindings for the header labels: -
- If the mouse pointer is on the right edge of a
header label or within a few pixels of its right edge, and both the
value of the
-resizablecolumns
configuration option and that of the-resizable
option for the column corresponding to that label are true, then the mouse cursor takes on the shape specified by the-resizecursor
option. By clicking mouse button 1 in this area and moving the mouse while its button 1 is down, the column corresponding to that label will be resized by the amount of the cursor motion. The interactive column resizing ends when mouse button 1 is released, and can be canceled by pressing theEscape
key. In both cases, the mouse cursor is reset to its original value, specified by the-cursor
configuration option. When the column resize operation is finished, the virtual event<<TablelistColumnResized>>
is generated, with its-data
option set to the numerical column index for Tk versions 8.5 or higher. - If mouse button 1 is pressed over a header label but
outside the resize area described above and then dragged outside
the label, and the value of the
-movablecolumns
configuration option is true, then the mouse cursor takes on the shape specified by the-movecolumncursor
option, indicating that the column in question is being moved to another position, visualized with the aid of a gap placed before the label of the target column. This operation ends when mouse button 1 is released, and can be canceled by pressing theEscape
key when the mouse pointer is outside the label. In both cases, the mouse cursor is reset to its original value, specified by the-cursor
configuration option. After releasing mouse button 1, the source column is moved before the one indicated by the gap mentioned above and the virtual event<<TablelistColumnMoved>>
is generated. For Tk versions 8.5 or higher, this virtual event is generated with its-data
option set to a list of length 4, whose first two elements are identical to the two numerical column indices passed to themovecolumn
subcommand invoked for moving the source column to its new position, and the last two elements are the corresponding column names, retrieved with the aid of thecolumncget ... -name
subcommand. - If mouse button 1 is pressed over a header label but
outside the resize area described above and later released over the
same label, and the command specified by the
-labelcommand
option is a nonempty string, then this command is concatenated with the name of the tablelist widget and the column index of the respective label, and the resulting script is evaluated in the global scope. If another nonempty label command was specified at column level by using thecolumnconfigure
option of the Tcl command associated with the tablelist widget, then that column-specific command will be used instead of the global one. If mouse button 1 was pressed together with theShift
key then the widget- or column-specific command mentioned above will be replaced with the one specified by the-labelcommand2
option at widget or column level. - The Tablelist package defines the
virtual event
<<Button3>>
as<Button-3>
for all windowing systems and additionally as<Control-Button-1>
for Mac OS Classic and Mac OS X Aqua. If this event occurs over a header label and both the value of the-resizablecolumns
configuration option and that of the-resizable
option for the column corresponding to that label are true, then the width of that column is set to zero, i.e., it is made just large enough to hold all the elements in the column, including the header (but no larger than the maximum width indicated by the-maxwidth
column configuration option), and the virtual event<<TablelistColumnResized>>
is generated, with its-data
option set to the numerical column index for Tk versions 8.5 or higher. The same action is triggered by double-clicking the resize area of a header label. - The Tablelist package defines the virtual event
<<ShiftButton3>>
as<Shift-Button-3>
for all windowing systems and additionally as<Shift-Control-Button-1>
for Mac OS Classic and Mac OS X Aqua. If this event occurs over a header label and both the value of the-resizablecolumns
configuration option and that of the-resizable
option for the column corresponding to that label are true, then the width of that column is set to its last static width (if any) and the virtual event<<TablelistColumnResized>>
is generated, with its-data
option set to the numerical column index for Tk versions 8.5 or higher. The same action is triggered by double-clicking the resize area of a header label with theShift
key held down.
- If the mouse pointer is on the right edge of a
header label or within a few pixels of its right edge, and both the
value of the
- If the tablelist's
state
isdisabled
then none of the above actions occur: the labels are completely insensitive. - If you want to define non-default bindings for the
header labels, it is recommended to associate them with the binding
tag whose name is returned by the
labeltag
subcommand and make use of the helper commandstablelist::getTablelistColumn
andtablelist::getTablelistPath
. For example, to replace the default binding for<Button-3>
with a script that performs a column-dependent action, you can proceed like in the code shown below:bind [.tbl labeltag] <Button-3> { puts "right-clicked on header label no. [tablelist::getTablelistColumn %W]" break }
- DEFAULT BINDINGS FOR INTERACTIVE CELL EDITING
- The
tablelist::tablelist
command extends and partially redefines the bindings of some of the components of the temporary embedded widget used for interactive cell editing, which is started by pressing mouse button 1 in an editable cell (see the-editselectedonly
option for details) or using keyboard navigation to move from one editable cell into another. If the selection type iscell
and the location cursor is in an editable cell, then the interactive editing of the active element can also be started by pressingReturn
orKP_Enter
. - The affected components of the temporary embedded
widget depend on the edit window: the widget itself in case of a Tk
or tile checkbutton or menubutton; the edit window's entry children
in case of a mentry widget; the only entry or entry-like component
of the edit window in all other cases (see also the
entrypath
subcommand). The list of binding tags of these edit window components contains two addditional tags, inserted just before their path names: the binding tag whose name is returned by theeditwintag
subcommand, followed by the tagTablelistEdit
. The bindings described below are associated with the tagTablelistEdit
, and can be overridden for individual tablelist widgets by making use of the binding tag given by theeditwintag
subcommand. -
Control-i
inserts a tabulator character into the edit window's entry or entry-like components (if any), at the point of the insertion cursor.Control-j
inserts a newline character into the edit window's entry or entry-like components (if any), at the point of the insertion cursor.- If the edit window is a text or ctext widget then
Return
andKP_Enter
insert a newline character at the point of the insertion cursor. Otherwise they terminate the editing and destroy the edit window. Control-Return
andControl-KP_Enter
terminate the editing and destroy the edit window.Escape
aborts the editing and destroys the edit window.- A click with the left mouse button anywhere in the tablelist's body, outside the cell just being edited, terminates the editing in the current cell and destroys the edit window or moves it into the cell that was just clicked into if the latter is editable.
- When editing a cell that is not the only editable
cell of the tablelist widget,
Tab
andShift-Tab
terminate the editing in the current cell, move the edit window into the next/previous editable cell of the tablelist, select the contents of the edit window's first entry or entry-like component (if any), and set the insertion cursor to its end. If the new edit window is a text or ctext widget then its contents are left unselected. Notice that these bindings replace the common inter-widget navigation viaTab
andShift-Tab
with inter-cell navigation. Just like in the case of the text widget,Control-Tab
andControl-Shift-Tab
are intended to be used for widget-to-widget keyboard navigation during interactive cell editing. Unfortunately, this won't always work because some window managers intercept the latter key sequences and use them for their own purposes (like inter-workplace navigation). For this reason, Tablelist supports the additional key sequencesMeta-Tab
andMeta-Shift-Tab
as replacements forControl-Tab
andControl-Shift-Tab
, respectively. - When editing a cell that is not the first/last
editable cell within its row,
Alt-Left
/Alt-Right
(Command-Left
/Command-Right
on Mac OS Classic and Mac OS X Aqua) terminates the editing in the current cell, moves the edit window into the previous/next editable cell of the row, selects the contents of the edit window's first entry or entry-like component (if any), and sets the insertion cursor to its end. If the new edit window is a text or ctext widget then its contents are left unselected. The key sequenceMeta-Left
/Meta-Right
has the same effect asAlt-Left
/Alt-Right
. Iftk_strictMotif
is false and the edit window is not a text or ctext widget thenMeta-b
andMeta-f
behave the same asAlt-Left
andAlt-Right
, respectively. If the edit window is a Tk or tile checkbutton or menubutton widget thenLeft
/Right
has the same effect asAlt-Left
/Alt-Right
. - When editing a cell that is not the first/last
editable cell within its column,
Alt-Up
/Alt-Down
(Command-Up
/Command-Down
on Mac OS Classic and Mac OS X Aqua) terminates the editing in the current cell, moves the edit window one line up/down within the column, selects the contents of the edit window's first entry or entry-like component (if any), and sets the insertion cursor to its end. If the new edit window is a text or ctext widget then its contents are left unselected. The key sequenceMeta-Up
/Meta-Down
has the same effect asAlt-Up
/Alt-Down
. Iftk_strictMotif
is false and the edit window is not a text or ctext widget or an Iwidgets combobox, thenControl-p
andControl-n
behave the same asAlt-Up
andAlt-Down
, respectively. If the edit window is a Tk or tile entry, Tk or tile checkbutton, Tk or tile menubutton, BWidget Entry, Iwidgets entryfield/spinner/spinint, or a mentry widget of type"FixedPoint"
, thenUp
/Down
has the same effect asAlt-Up
/Alt-Down
. - When editing a cell that is not the first/last
editable cell within its column,
Alt-Prior
/Alt-Next
(Command-Prior
/Command-Next
on Mac OS Classic and Mac OS X Aqua) terminates the editing in the current cell, moves the edit window up/down by one page within the column, selects the contents of the edit window's first entry or entry-like component (if any), and sets the insertion cursor to its end. If the new edit window is a text or ctext widget then its contents are left unselected. The key sequenceMeta-Prior
/Meta-Next
has the same effect asAlt-Prior
/Alt-Next
. If the edit window is not a text or ctext widget, BWidget SpinBox, Oakley combobox, or a mentry widget of type"Date"
,"Time"
,"DateTime"
,"IPAddr"
, or"IPv6Addr"
, thenPrior
/Next
has the same effect asAlt-Prior
/Alt-Next
. - When editing a cell that is not the only editable
cell of the tablelist widget,
Alt-Home
/Alt-End
(Command-Home
/Command-End
on Mac OS Classic and Mac OS X Aqua) terminates the editing in the current cell, moves the edit window into the first/last editable cell of the tablelist, selects the contents of the edit window's first entry or entry-like component (if any), and sets the insertion cursor to its end. If the new edit window is a text or ctext widget then its contents are left unselected. The key sequenceMeta-Home
/Meta-End
has the same effect asAlt-Home
/Alt-End
. Iftk_strictMotif
is false and the edit window is not a text or ctext widget thenMeta-<
andMeta->
behave the same asAlt-Home
andAlt-End
, respectively. If the edit window is not a text or ctext widget thenControl-Home
/Control-End
has the same effect asAlt-Home
/Alt-End
.
- Before moving the edit window, the key sequences
mentioned under 7 - 11 move the active item or element and change
the (cell)selection and the (cell)selection anchor in the body of
the tablelist widget. For example, if
Alt-Up
/Alt-Down
orMeta-Up
/Meta-Down
(Command-Up
/Command-Down
on Mac OS Classic and Mac OS X Aqua) is pressed when editing a cell that is not the first/last editable cell within its column, then the active item or element (depending on the selection type) moves one line up/down. If the selection mode isbrowse
orextended
then the new active item or element is also selected and all other items or elements are deselected. Inextended
mode the new active item or element becomes the (cell)selection anchor. This is exactly the same behavior as the one exhibited by theUp
andDown
keys in the tablelist's body. - If the tablelist's
state
isdisabled
then none of the above actions occur. - KEYWORDS
- tablelist, multi-column, listbox, tree, widget