NAME
table - Create and manipulate tables
SYNOPSIS
ttaabbllee pathName ?options? SSTTAANNDDAARRDD OOPPTTIIOONNSS-aanncchhoorr -bbaacckkggrroouunndd -ccuurrssoorr
-eexxppoorrttsseelleeccttiioonn -ffoonntt -ffoorreeggrroouunndd
-hhiigghhlliigghhttbbaacckkggrroouunndd -hhiigghhlliigghhttccoolloorr -hhiigghhlliigghhtttthhiicckknneessss
-iinnsseerrttbbaacckkggrroouunndd -iinnsseerrttbboorrddeerrwwiiddtthh-iinnsseerrttooffffttiimmee
-iinnsseerrttoonnttiimmee -iinnsseerrttwwiiddtthh -iinnvveerrttsseelleecctteedd
-rreelliieeff -ttaakkeeffooccuuss -xxssccrroollllccoommmmaanndd
-yyssccrroollllccoommmmaanndd
See the ooppttiioonnss manual entry for details on the standard options.WWIIDDGGEETT-SSPPEECCIIFFIICC OOPPTTIIOONNSS
Command-Line Name:-aauuttoocclleeaarr
Database Name: aauuttooCClleeaarr Database Class: AAuuttooCClleeaarr A boolean value which specifies whether the first keypress in a cell will delete whatever text was previously there. Defaults to 0.Command-Line Name:-bboorrddeerrccuurrssoorr
Database Name: bboorrddeerrCCuurrssoorr Database Class: CCuurrssoorr Specifies the name of the cursor to show when over borders, a visual indication that interactive resizing is allowed (it isthus affect by the value of -resizeborders). Defaults to
crosshair.Command-Line Name:-bboorrddeerrwwiiddtthh oorr -bbdd
Database Name: bboorrddeerrWWiiddtthh Database Class: BBoorrddeerrWWiiddtthhSpecifies a non-negative pixel value or list of values indicat-
ing the width of the 3-D border to draw on interior table cells
(if such a border is being drawn; the rreelliieeff option typically determines this). If one value is specified, a rectangle of this width will be drawn. If two values are specified, then only the left and right edges of the cell will have borders. If four values are specified, then the values correspond to the {left right top bottom} edges. This can be overridden by the a tag's borderwidth option. It can also be affected by thedefined -ddrraawwmmooddee for the table. Each value in the list must
have one of the forms acceptable to TTkkGGeettPPiixxeellss.Command-Line Name:-bbrroowwsseeccoommmmaanndd oorr -bbrroowwsseeccmmdd
Database Name: bbrroowwsseeCCoommmmaanndd Database Class: BBrroowwsseeCCoommmmaanndd Specifies a command which will be evaluated anytime the activecell changes. It uses the %-substition model described in COM-
MAND SUBSTITUTION below.Command-Line Name:-ccaacchhee
Database Name: ccaacchhee Database Class: CCaacchhee A boolean value that specifies whether an internal cache of thetable contents should be kept. This greatly enhances speed per-
formance when used with -ccoommmmaanndd but uses extra memory. Can
maintain state when both -ccoommmmaanndd and -vvaarriiaabbllee are empty. The
cache is automatically flushed whenever the value of -ccaacchhee or
-vvaarriiaabbllee changes, otherwise you have to explicitly call cclleeaarr
on it. Defaults to off.Command-Line Name:-ccoolloorriiggiinn
Database Name: ccoollOOrriiggiinn Database Class: OOrriiggiinn Specifies what column index to interpret as the leftmost column in the table. This value is used for user indices in the table. Defaults to 0.Command-Line Name:-ccoollss
Database Name: ccoollss Database Class: CCoollss Number of cols in the table. Defaults to 10.Command-Line Name:-ccoollsseeppaarraattoorr
Database Name: ccoollSSeeppaarraattoorr Database Class: SSeeppaarraattoorr Specifies a separator character that will be interpreted as the column separator when cutting or pasting data in a table. By default, columns are separated as elements of a tcl list.Command-Line Name:-ccoollssttrreettcchhmmooddee
Database Name: ccoollSSttrreettcchhMMooddee Database Class: SSttrreettcchhMMooddee Specifies one of the following stretch modes for columns to fill extra allocated window space: nnoonnee Columns will not stretch to fill the assigned window space. If the columns are too narrow, there will be a blank space at the right of the table. This is the default. uunnsseett Only columns that do not have a specific width set will be stretched.aallll All columns will be stretched by the same number of pix-
els to fill the window space allocated to the table. This mode can interfere with interactive border resizing which tries to force column width. llaasstt The last column will be stretched to fill the window space allocated to the table.ffiillll (only valid for -rroowwssttrreettcchh currently)
The table will get more or less columns according to the window space allocated to the table. This mode has numerous quirks and may disappear in the future.Command-Line Name:-ccoollttaaggccoommmmaanndd
Database Name: ccoollTTaaggCCoommmmaanndd Database Class: TTaaggCCoommmmaanndd Provides the name of a procedure that will be evaluated by the widget to determine the tag to be used for a given column. When displaying a cell, the table widget will first check to see if a tag has been defined using the ttaagg ccooll widget method. If no tagis found, it will evaluate the named procedure passing the col-
umn number in question as the sole argument. The procedure is expected to return the name of a tag to use, or a null string. Errors occuring during the evaluation of the procedure, or the return of an invalid tag name are silently ignored.Command-Line Name:-ccoollwwiiddtthh
Database Name: ccoollWWiiddtthh Database Class: CCoollWWiiddtthh Default column width, interpreted as characters in the default font when the number is positive, or pixels if it is negative. Defaults to 10.Command-Line Name:-ccoommmmaanndd
Database Name: ccoommmmaanndd Database Class: CCoommmmaanndd Specified a command to use as a procedural interface to cellvalues. If -uusseeccoommmmaanndd is true, this command will be used
instead of any reference to the -vvaarriiaabbllee array. When retriev-
ing cell values, the return value of the command is used as thevalue for the cell. It uses the %-substition model described in
COMMAND SUBSTITUTION below.Command-Line Name:-ddrraawwmmooddee
Database Name: ddrraawwMMooddee Database Class: DDrraawwMMooddee Sets the table drawing mode to one of the following options: ssllooww The table is drawn to an offscreen pixmap using the Tkbordering functions (double-buffering). This means there
will be no flashing, but this mode is slow for larger tables. ccoommppaattiibbllee The table is drawn directly to the screen using the Tk border functions. It is faster, but the screen may flash on update. This is the default. ffaasstt The table is drawn directly to the screen and the borders are done with fast X calls, so they are always one pixelwide only. As a side effect, it restricts -bboorrddeerrwwiiddtthh
to a range of 0 or 1. This mode provides best perfor-
mance for large tables, but can flash on redraw and isnot 100% Tk compatible on the border mode.
ssiinnggllee The table is drawn to the screen as in fast mode, but only single pixel lines are drawn (not square borders).Command-Line Name:-eelllliippssiiss
Database Name: eelllliippssiiss Database Class: EElllliippssiiss This specifies a string to display at the end of a line that would be clipped by its cell, like ``...''. An ellipsis will bedisplayed only on non-wrapping, non-multiline cells that would
be clipped. The ellipsis will display on the left for east anchored cells, otherwise it displays on the right. Defaults to "" (no ellipsis).Command-Line Name:-ffllaasshhmmooddee
Database Name: ffllaasshhMMooddee Database Class: FFllaasshhMMooddee A boolean value which specifies whether cells should flash when their value changes. The table tag ffllaasshh will be applied tothese cells for the duration specified by -ffllaasshhttiimmee. Defaults
to 0.Command-Line Name:-ffllaasshhttiimmee
Database Name: ffllaasshhTTiimmee Database Class: FFllaasshhTTiimmee The amount of time, in 1/4 second increments, for which a cellshould flash when its value has changed. -ffllaasshhmmooddee must be on.
Defaults to 2.Command-Line Name:-hheeiigghhtt
Database Name: hheeiigghhtt Database Class: HHeeiigghhtt Specifies the desired height for the window, in rows. If zero or less, then the desired height for the window is made just large enough to hold all the rows in the table. The height canbe further limited by -mmaaxxhheeiigghhtt.
Command-Line Name:-iinnvveerrttsseelleecctteedd
Database Name: iinnvveerrttSSeelleecctteedd Database Class: IInnvveerrttSSeelleecctteedd Specifies whether the foreground and background of an item should simply have their values swapped instead of merging the sel tag options when the cell is selected. Defaults to 0 (merge sel tag).Command-Line Name:-iippaaddxx
Database Name: iippaaddXX Database Class: PPaadd A pixel value specifying the internal offset X padding for text in a cell. This value does not grow the size of the cell, it just causes the text to be drawn further from the cell border. It only affects one side (depending on anchor). Defaults to 0.See -ppaaddxx for an alternate padding style.
Command-Line Name:-iippaaddyy
Database Name: iippaaddYY Database Class: PPaadd A pixel value specifying the internal offset Y padding for text in a cell. This value does not grow the size of the cell, it just causes the text to be drawn further from the cell border. It only affects one side (depending on anchor). Defaults to 0.See -ppaaddyy for an alternate padding style.
Command-Line Name:-jjuussttiiffyy
Database Name: jjuussttiiffyy Database Class: JJuussttiiffyyHow to justify multi-line text in a cell. It must be one of
lleefftt, rriigghhtt, or cceenntteerr. Defaults to left.Command-Line Name:-mmaaxxhheeiigghhtt
Database Name: mmaaxxHHeeiigghhtt Database Class: MMaaxxHHeeiigghhtt The max height in pixels that the window will request. Defaults to 600.Command-Line Name:-mmaaxxwwiiddtthh
Database Name: mmaaxxWWiiddtthh Database Class: MMaaxxWWiiddtthh The max width in pixels that the window will request. Defaults to 800.Command-Line Name:-mmuullttiilliinnee
Database Name: mmuullttiilliinnee Database Class: MMuullttiilliinnee Specifies the default setting for the multiline tag option. Defaults to 1.Command-Line Name:-ppaaddxx
Database Name: ppaaddXX Database Class: PPaadd A pixel value specifying the offset X padding for a cell. This value causes the default size of the cell to increase by two times the value (one for each side), unless a specific pixel size is chosen for the cell with the wwiiddtthh command. This will force an empty area on the left and right of each cell edge. This padding affects all types of data in the cell. Defaults to0. See -iippaaddxx for an alternate padding style.
Command-Line Name:-ppaaddyy
Database Name: ppaaddYY Database Class: PPaadd A pixel value specifying the offset Y padding for a cell. This value causes the default size of the cell to increase by two times the value (one for each side), unless a specific pixel size is chosen for the cell with the hheeiigghhtt command. This will force an empty area on the top and bottom of each cell edge. This padding affects all types of data in the cell. Defaults to0. See -iippaaddxx for an alternate padding style.
Command-Line Name:-rreessiizzeebboorrddeerrss
Database Name: rreessiizzeeBBoorrddeerrss Database Class: RReessiizzeeBBoorrddeerrss Specifies what kind of interactive border resizing to allow, must be one of row, col, both (default) or none.Command-Line Name:-rroowwhheeiigghhtt
Database Name: rroowwHHeeiigghhtt Database Class: RRoowwHHeeiigghhtt Default row height, interpreted as lines in the default font when the number is positive, or pixels if it is negative. Defaults to 1.Command-Line Name:-rroowwoorriiggiinn
Database Name: rroowwOOrriiggiinn Database Class: OOrriiggiinn Specifies what row index to interpret as the topmost row in the table. This value is used for user indices in the table. Defaults to 0.Command-Line Name:-rroowwss
Database Name: rroowwss Database Class: RRoowwss Number of rows in the table. Defaults to 10.Command-Line Name:-rroowwsseeppaarraattoorr
Database Name: rroowwSSeeppaarraattoorr Database Class: SSeeppaarraattoorr Specifies a separator character that will be interpreted as the row separator when cutting or pasting data in a table. By default, rows are separated as tcl lists.Command-Line Name:-rroowwssttrreettcchhmmooddee
Database Name: rroowwSSttrreettcchhMMooddee Database Class: SSttrreettcchhMMooddee Specifies the stretch modes for rows to fill extra allocatedwindow space. See -ccoollssttrreettcchhmmooddee for valid options.
Command-Line Name:-rroowwttaaggccoommmmaanndd
Database Name: rroowwTTaaggCCoommmmaanndd Database Class: TTaaggCCoommmmaannddProvides the name of a procedure that can evaluated by the wid-
get to determine the tag to be used for a given row. The proce-
dure must be defined by the user to accept a single argument (the row number), and return a tag name or null string. Thisoperates in a similar manner as -ccoollttaaggccoommmmaanndd, except that it
applies to row tags.Command-Line Name:-sseelleeccttiioonnccoommmmaanndd oorr -sseellccmmdd
Database Name: sseelleeccttiioonnCCoommmmaanndd Database Class: SSeelleeccttiioonnCCoommmmaanndd Specifies a command to evaluate when the selection is retrievedfrom a table via the selection mechanism (ie: evaluating "sseelleecc-
ttiioonn ggeett"). The return value from this command will become thestring passed on by the selection mechanism. It uses the %-sub-
stition model described in COMMAND SUBSTITUTION below. If an error occurs, a Tcl background error is generated and nothing is returned.Command-Line Name:-sseelleeccttmmooddee
Database Name: sseelleeccttMMooddee Database Class: SSeelleeccttMMooddee Specifies one of several styles for manipulating the selection.The value of the option may be arbitrary, but the default bind-
ings expect it to be either ssiinnggllee, bbrroowwssee, mmuullttiippllee, or eexxtteennddeedd; the default value is bbrroowwssee. These styles are like those for the Tk listbox, except expanded for 2 dimensions.Command-Line Name:-sseelleeccttttiittllee
Database Name: sseelleeccttTTiittlleess Database Class: SSeelleeccttTTiittlleessSpecifies whether title cells should be allowed in the selec-
tion. Defaults to 0 (disallowed).Command-Line Name:-sseelleeccttttyyppee
Database Name: sseelleeccttTTyyppee Database Class: SSeelleeccttTTyyppee Specifies one of several types of selection for the table. Thevalue of the option may be one of rrooww, ccooll, cceellll, or bbootthh (mean-
ing rrooww &&&& ccooll); the default value is cceellll. These types define whether an entire row/col is affected when a cell's selection is changed (set or clear).Command-Line Name:-ssppaarrsseeaarrrraayy
Database Name: ssppaarrsseeAArrrraayy Database Class: SSppaarrsseeAArrrraayy A boolean value that specifies whether an associated Tcl array should be kept as a sparse array (1, the default) or as a full array (0). If true, then cell values that are empty will be deleted from the array (taking less memory). If false, then all values in the array will be maintained.Command-Line Name:-ssttaattee
Database Name: ssttaattee Database Class: SSttaattee Specifies one of two states for the entry: nnoorrmmaall or ddiissaabblleedd. If the table is disabled then the value may not be changed using widget commands and no insertion cursor will be displayed, even if the input focus is in the widget. Also, all insert or delete methods will be ignored. Defaults to nnoorrmmaall.Command-Line Name:-ttiittlleeccoollss
Database Name: ttiittlleeCCoollss Database Class: TTiittlleeCCoollss Number of columns to use as a title area. Defaults to 0.Command-Line Name:-ttiittlleerroowwss
Database Name: ttiittlleeRRoowwss Database Class: TTiittlleeRRoowwss Number of rows to use as a title area. Defaults to 0.Command-Line Name:-uusseeccoommmmaanndd
Database Name: uusseeCCoommmmaanndd Database Class: UUsseeCCoommmmaanndd A boolean value which specifies whether to use the ccoommmmaanndd option. This value sets itself to zero if ccoommmmaanndd is used andreturns an error. Defaults to 1 (will use ccoommmmaanndd if speci-
fied).Command-Line Name:-vvaalliiddaattee
Database Name: vvaalliiddaattee Database Class: VVaalliiddaattee A boolean specifying whether validation should occur for the active buffer. Defaults to 0.Command-Line Name:-vvaalliiddaatteeccoommmmaanndd oorr -vvccmmdd
Database Name: vvaalliiddaatteeCCoommmmaanndd Database Class: VVaalliiddaatteeCCoommmmaanndd Specifies a command to execute when the active cell is edited. This command is expected to return a Tcl boolean. If it returns true, then it is assumed the new value is OK, otherwise the new value is rejected (the edition will not take place). Errors inthis command are handled in the background. It uses the %-sub-
stition model described in COMMAND SUBSTITUTION below.Command-Line Name:-vvaarriiaabbllee
Database Name: vvaarriiaabbllee Database Class: VVaarriiaabbllee Global Tcl array variable to attach to the table's C array. Itwill be created if it doesn't already exist or is a simple vari-
able. Keys used by the table in the array are of the form row,col for cells and the special key active which contains the value of the active cell buffer. The Tcl array is managed as a sparse array (the table doesn't require all valid indices have values). No stored value for an index is equivalent to the empty string, and clearing a cell will remove that index fromthe Tcl array, unless the -ssppaarrsseeaarrrraayy options is set to 0.
Command-Line Name:-wwiiddtthh
Database Name: wwiiddtthh Database Class: WWiiddtthh Specifies the desired width for the window, in columns. If zero or less, then the desired width for the window is made just large enough to hold all the columns in the table. The widthcan be further limited by -mmaaxxwwiiddtthh.
Command-Line Name:-wwrraapp
Database Name: wwrraapp Database Class: WWrraapp Specifies the default wrap value for tags. Defaults to 0.DESCRIPTION
The ttaabbllee command creates a 2-dimensional grid of cells. The table can
use a Tcl array variable or Tcl command for data storage and retrieval, as well as optionally cache data in memory for speed. One of thesedata sources must be configured before any data is retained by the ta-
ble. The widget has an active cell, the contents of which can be edited (when the state is normal). The widget supports a default style for the cells and also multiple tags, which can be used to change the style of a row, column or cell (see TAGS for details). A cell flash can be set up so that changed cells will change color for a specified amount of time ("blink"). Cells can have embedded images or windows, as described in TAGS and "EMBEDDED WINDOWS" respectively. One or more cells may be selected as described below. If a table isexporting its selection (see -eexxppoorrttsseelleeccttiioonn option), then it will
observe the standard X11 protocols for handling the selection. See THE SELECTION for details.It is not necessary for all the cells to be displayed in the table win-
dow at once; commands described below may be used to change the view inthe window. Tables allow scrolling in both directions using the stan-
dard -xxssccrroollllccoommmmaanndd and -yyssccrroollllccoommmmaanndd options. They also support
scanning, as described below. In order to obtain good performance, the table widget supports multiple drawing modes, two of which are fully Tk compatible. IINNIITTIIAALLIIZZAATTIIOONNWhen the ttaabbllee command is loaded into an interpreter, a built-in Tcl
command, ttkkTTaabblleeIInniitt, is evaluated. This will search for the appropri-
ate table binding init file to load. The directories searched arethose in $tclpkgPath, both with Tktable(version) appended and without,
$tklibrary and [pwd] (the current directory). You can also define an
$env(TKTABLELIBRARY) to head this search list. By default, the file
searched for is called ttkkTTaabbllee..ttccll, but this can be overridden by set-
ting $env(TKTABLELIBRARYFILE).
This entire init script can be overridden by providing your own ttkkTTaabblleeIInniitt procedure before the library is loaded. Otherwise, the aforementioned env(TKTABLELIBRARY) variable will be set with thedirectory in which $env(TKTABLELIBRARYFILE) was found.
IINNDDIICCEESS Many of the widget commands for tables take one or more indices as arguments. An index specifies a particular cell of the table, in any of the following ways: number,number Specifies the cell as a numerical index of row,col which corresponds to the index of the associated Tcl array, where-rroowwoorriiggiinn,,-ccoolloorriiggiinn corresponds to the first cell in the
table (0,0 by default). The values for row and column will be constrained to actual values in the table, which means a valid cell is always found. aaccttiivvee Indicates the cell that has the location cursor. It is specified with the aaccttiivvaattee widget command. aanncchhoorr Indicates the anchor point for the selection, which is set with the sseelleeccttiioonn aanncchhoorr widget command.bboottttoommrriigghhtt Indicates the bottom-rightmost cell visible in the table.
eenndd Indicates the bottom right cell of the table.oorriiggiinn Indicates the top-leftmost editable cell of the table, not
necessarily in the display. This takes into account the user specified origin and title area.ttoopplleefftt Indicates the top-leftmost editable cell visible in the ta-
ble (this excludes title cells).@@x,,y Indicates the cell that covers the point in the table win-
dow specified by x and y (in pixel coordinates). If no cell covers that point, then the closest cell to that point is used. In the widget command descriptions below, arguments named index, first, and last always contain text indices in one of the above forms. TTAAGGSS A tag is a textual string that is associated with zero or more rows, columns or cells in a table. Tags may contain arbitrary characters, but it is probably best to avoid using names which look like indices to reduce coding confusion. A tag can apply to an entire row or column, or just a single cell. There are several permanent tags in each table that can be configured by the user and will determine the attributes for special cells: aaccttiivvee This tag is given to the active cell ffllaasshh If flash mode is on, this tag is given to any recently edited cells. sseell This tag is given to any selected cells. ttiittllee This tag is given to any cells in the title rows andcolumns. This tag has -ssttaattee disabled by default.
Tags control the way cells are displayed on the screen. Where appro-
priate, the default for displaying cells is determined by the options for the table widget. However, display options may be associated with individual tags using the ``pathName ttaagg ccoonnffiigguurree'' widget command. If a cell, row or column has been tagged, then the display optionsassociated with the tag override the default display style. The fol-
lowing options are currently supported for tags:-aanncchhoorr anchor
Anchor for item in the cell space.-bbaacckkggrroouunndd or -bbgg color
Background color of the cell.-bboorrddeerrwwiiddtthh or -bbdd pixelList
Borderwidth of the cell, of the same format for the ta-
ble, but may also be empty to inherit the default table borderwidth value (the default).-eelllliippssiiss string
String to display at the end of a line that would be clipped by its cell, like ``...''. An ellipsis will bedisplayed only on non-wrapping, non-multiline cells that
would be clipped. The ellipsis will display on the left for east anchored cells, otherwise it displays on the right.-ffoonntt fontName
Font for text in the cell.-ffoorreeggrroouunndd or -ffgg color
Foreground color of the cell.-jjuussttiiffyy justify
How to justify multi-line text in a cell. It must be one
of lleefftt, rriigghhtt, or cceenntteerr.-iimmaaggee imageName
An image to display in the cell instead of text.-mmuullttiilliinnee boolean
Whether to display text with newlines on multiple lines.-rreelliieeff relief
The relief for the cell. May be the empty string to cause this tag to not disturb the value.-sshhoowwtteexxtt boolean
Whether to show the text over an image.-ssttaattee state
The state of the cell, to allow for certain cells to be disabled. This prevents the cell from being edited by the insert or delete methods, but a direct set will not be prevented.-wwrraapp boolean
Whether characters should wrap in a cell that is not wide enough. A priority order is defined among tags based on creation order (first created tag has highest default priority), and this order is used inimplementing some of the tag-related functions described below. When a
cell is displayed, its properties are determined by the tags which areassigned to it. The priority of a tag can be modified by the ``path-
Name ttaagg lloowweerr'' and ``pathName ttaagg rraaiissee'' widget commands.If a cell has several tags associated with it that define the same dis-
play options (eg - a ttiittllee cell with specific rrooww and cceellll tags), then
the options of the highest priority tag are used. If a particular dis-
play option hasn't been specified for a particular tag, or if it is specified as an empty string, then that option will not be used; thenext-highest-priority tag's option will be used instead. If no tag
specifies a particular display option, then the default style for the widget will be used. Images are used for display purposes only. Editing in that cell will still be enabled and any querying of the cell will show the text valueof the cell, regardless of the value of -sshhoowwtteexxtt.
EEMMBBEEDDDDEEDD WWIINNDDOOWWSS There may be any number of embedded windows in a table widget (one per cell), and any widget may be used as an embedded window (subject to the usual rules for geometry management, which require the table window to be the parent of the embedded window or a descendant of its parent).The embedded window's position on the screen will be updated as the ta-
ble is modified or scrolled, and it will be mapped and unmapped as it moves into and out of the visible area of the table widget. Each embedded window occupies one cell's worth of space in the table widget, and it is referred to by the index of the cell in the table. Windows associated with the table widget are destroyed when the table widget is destroyed. Windows are used for display purposes only. A value still exists for that cell, but will not be shown unless the window is deleted in some way. If the window is destroyed or lost by the table widget to another geometry manager, then any data associated with it is lost (the cell it occupied will no longer appear in wwiinnddooww nnaammeess).When an embedded window is added to a table widget with the window con-
figure widget command, several configuration options may be associated with it. These options may be modified with later calls to the windowconfigure widget command. The following options are currently sup-
ported:-ccrreeaattee script
NOT CURRENTLY SUPPORTED. Specifies a Tcl script that may be evaluated to create the window for the annotation. Ifno -window option has been specified for this cell then
this script will be evaluated when the cell is about to be displayed on the screen. Script must create a window for the cell and return the name of that window as its result. If the cell's window should ever be deleted, the script will be evaluated again the next time the cell is displayed.-bbaacckkggrroouunndd or -bbgg color
Background color of the cell. If not specified, it uses the table's default background.-bboorrddeerrwwiiddtthh or -bbdd pixelList
Borderwidth of the cell, of the same format for the ta-
ble, but may also be empty to inherit the default table borderwidth value (the default).-ppaaddxx pixels
As defined in the Tk options man page.-ppaaddyy pixels
As defined in the Tk options man page.-rreelliieeff relief
The relief to use for the cell in which the window lies. If not specified, it uses the table's default relief.-ssttiicckkyy sticky
Stickiness of the window inside the cell, as defined by the ggrriidd command.-wwiinnddooww pathName
Specifies the name of a window (widget) to display in the annotation. It must exist before being specified here.When an empty string is specified, if a window was dis-
played it will cease to be managed by the table widget. TTHHEE SSEELLEECCTTIIOONN Table selections are available as type STRING. By default, the value of the selection will be the values of the selected cells in nested Tcl list form where each row is a list and each column is an element of a row list. You can change the way this value is interpreted by settingthe -rroowwsseeppaarraattoorr and -ccoollsseeppaarraattoorr options. For example, default
Excel format would be to set -rroowwsseeppaarraattoorr to "\n" and -ccoollsseeppaarraattoorr to
"\t". Changing these values affects both how the table sends out the selection and reads in pasted data, ensuring that the table should always be able to cut and paste to itself. It is possible to change how pastes are handled by editing the table library procedurettkkttaabblleePPaasstteeHHaannddlleerr. This might be necessary if -sseelleeccttiioonnccoommmmaanndd is
set. RROOWW//CCOOLL SSPPAANNNNIINNGG Individual cells can span multiple rows and/or columns. This is done via the ssppaannss command (see below for exact arguments). Cells in the title area that span are not permitted to span beyond the title area, and will be constrained accordingly. If the title area shrinks during a configure, sanity checking will occur to ensure the above. You may set spans on regular cells that extend beyond the defined row/col area. These spans will not be constrained, so that when the defined row/col area expands, the span will expand with it.When setting a span, checks are made as to whether the span would over-
lap an already spanning or hidden cell. This is an error and it not allowed. Spans can affect the overall speed of table drawing, although not significantly. If spans are not used, then there is no performance loss. Cells hidden by spanning cells still have valid data. This will be seen during cut and paste operations that involve hidden cells, or through direct access by a command like ggeett or sseett. The drawing properties of spanning cells apply to only the visual areaof the cell. For example, if a cell is center justified over 5 col-
umns, then when viewing any portion of those columns, it will appearcentered in the visible area. The non-visible column area will not be
considered in the centering calculations. CCOOMMMMAANNDD SSUUBBSSTTIITTUUTTIIOONN The various option based commands that the table supports all supportthe familiar Tk %-substitution model (see bbiinndd for more details). The
following %-sequences are recognized and substituted by the table wid-
get:%%cc For SSeelleeccttiioonnCCoommmmaanndd, it is the maximum number of columns in any
row in the selection. Otherwise it is the column of the triggered cell.%%CC A convenience substitution for %r,%c.
%%ii For SSeelleeccttiioonnCCoommmmaanndd, it is the total number of cells in the
selection. For CCoommmmaanndd, it is 0 for a read (get) and 1 for a write (set). Otherwise it is the current cursor position in the cell.%%rr For SSeelleeccttiioonnCCoommmmaanndd, it is the number of rows in the selection.
Otherwise it is the row of the triggered cell.%%ss For VVaalliiddaatteeCCoommmmaanndd, it is the current value of the cell being
validated. For SSeelleeccttiioonnCCoommmmaanndd, it is the default value of the selection. For BBrroowwsseeCCoommmmaanndd, it is the index of the last active cell. For CCoommmmaanndd, it is empty for reads (get) and the current value of the cell for writes (set).%%SS For VVaalliiddaatteeCCoommmmaanndd, it is the potential new value of the cell
being validated. For BBrroowwsseeCCoommmmaanndd, it is the index of the new active cell.%%WW The pathname to the window for which the command was generated.
WWIIDDGGEETT CCOOMMMMAANNDD The ttaabbllee command creates a new Tcl command whose name is pathName. This command may be used to invoke various operations on the widget. It has the following general form: pathName option ?arg arg ...? Option and the args determine the exact behavior of the command. The following commands are possible for ttaabbllee widgets: pathName aaccttiivvaattee index Sets the active cell to the one indicated by index. pathName bbbbooxx first ?last? It returns the bounding box for the specified cell (range) as a4-tuple of x, y, width and height in pixels. It clips the box
to the visible portion, if any, otherwise an empty string is returned. pathName bboorrddeerr option args This command is a voodoo hack to implement border sizing fortables. This is normally called through bindings, with the fol-
lowing as valid options: pathName bboorrddeerr mmaarrkk x y ?row|col? Records x and y and the row and/or column border underthat point in the table window, if any; used in conjunc-
tion with later bboorrddeerr ddrraaggttoo commands. Typically this command is associated with a mouse button press in the widget. If row or col is not specified, it returns atuple of both border indices (an empty item means no bor-
der). Otherwise, just the specified item is returned. pathName bboorrddeerr ddrraaggttoo x y This command computes the difference between its x and y arguments and the x and y arguments to the last bboorrddeerrmmaarrkk command for the widget. It then adjusts the previ-
ously marked border by the difference. This command istypically associated with mouse motion events in the wid-
get, to produce the effect of interactive border resiz-
ing. pathName ccggeett option Returns the current value of the configuration option given by option. Option may have any of the values accepted by the ttaabbllee command. pathName cclleeaarr option ?first? ?last? This command is a convenience routine to clear certain state information managed by the table. first and last represent valid table indices. If neither are specified, then the commandoperates on the whole table. The following options are recog-
nized: pathName cclleeaarr ccaacchhee ?first? ?last? Clears the specified section of the cache, if the table has been keeping one. pathName cclleeaarr ssiizzeess ?first? ?last? Clears the specified row and column areas of specificheight/width dimensions. When just one index is speci-
fied, for example 22,,00, that is interpreted as row 2 aanndd column 0. pathName cclleeaarr ttaaggss ?first? ?last? Clears the specified area of tags (all row, column and cell tags). pathName cclleeaarr aallll ?first? ?last?Performs all of the above clear functions on the speci-
fied area. pathName ccoonnffiigguurree ?option? ?value option value ...? Query or modify the configuration options of the widget. If nooption is specified, returns a list describing all of the avail-
able options for pathName (see TTkkCCoonnffiigguurreeIInnffoo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one ormore option-value pairs are specified, then the command modifies
the given widget option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the ttaabbllee command. pathName ccuurrsseelleeccttiioonn ?value?With no arguments, it returns the sorted indices of the cur-
rently selected cells. Otherwise it sets all the selected cellsto the given value. The set has no effect if there is no asso-
ciated Tcl array or the state is disabled. pathName ccuurrvvaalluuee ?value? If no value is given, the value of the cell being edited (indexed by aaccttiivvee) is returned, else it is set to the given value. pathName ddeelleettee option arg ?arg? This command is used to delete various things in a table. It has several forms, depending on the option: pathName ddeelleettee aaccttiivvee index ?index? Deletes text from the active cell. If only one index isgiven, it deletes the character after that index, other-
wise it deletes from the first index to the second. index can be a number, iinnsseerrtt or eenndd. pathName ddeelleettee ccoollss ?switches? index ?count? Deletes count cols starting at (and including) col index. The index will be constrained to the limits of the tables. If count is negative, it deletes cols to the left. Otherwise it deletes cols to the right. count defaults to 1 (meaning just the column specified). At the moment, spans are not adjusted with this action. Optional switches are:-hhoollddddiimmeennssiioonnss
Causes the table cols to be unaffected by the deletion (empty cols may appear). By default the dimensions are adjusted by ccoouunntt.-hhoollddsseelleeccttiioonn
Causes the selection to be maintained on the abso-
lute cells values. Otherwise, the selection will be cleared..-hhoollddttaaggss
Causes the tags specified by the tag method to not move along with the data. Also prevents specific widths set by the width method from being adjusted. By default, these tags are properly adjusted.-hhoollddwwiinnddoowwss
Causes the embedded windows created with the win-
dow method to not move along with the data. By default, these windows are properly adjusted.-kkeeeeppttiittlleess
Prevents title area cells from being changed. Otherwise they are treated just like regular cells and will move as specified.-- Signifies the end of the switches.
pathName ddeelleettee rroowwss ?switches? index ?count? Deletes ccoouunntt rows starting at (and including) row iinnddeexx.If ccoouunntt is negative, it deletes rows going up. Other-
wise it deletes rows going down. The selection will be cleared. The switches are the same as those for column deletion. pathName ggeett first ?last? Returns the value of the cells specified by the table indices first and (optionally) last in a list. pathName hheeiigghhtt ?row? ?value row value ...? If no row is specified, returns a list describing all rows for which a height has been set. If rrooww is specified with no value, it prints out the height of that row in characters (positivenumber) or pixels (negative number). If one or more row-value
pairs are specified, then it sets each row to be that height in lines (positive number) or pixels (negative number). If value is default, then the row uses the default height, specified by-rroowwhheeiigghhtt.
pathName hhiiddddeenn ?index? ?index ...? When called without args, it returns all the hidden cells (those cells covered by a spanning cell). If one index is specified, it returns the spanning cell covering that index, if any. If multiple indices are specified, it returns 1 if all indices are hidden cells, 0 otherwise. pathName iiccuurrssoorr ?arg?With no arguments, prints out the location of the insertion cur-
sor in the active cell. With one argument, sets the cursor to that point in the string. 0 is before the first character, you can also use iinnsseerrtt or eenndd for the current insertion point or the end of the text. If there is no active cell, or the cell ortable is disabled, this will return -1.
pathName iinnddeexx index ?row|col? Returns the integer cell coordinate that corresponds to index in the form row,col. If rrooww or ccooll is specified, then only the row or column index is returned. pathName iinnsseerrtt option arg arg This command is used to into various things into a table. It has several forms, depending on the option: pathName iinnsseerrtt aaccttiivvee index value The value is a text string which is inserted at the indexpostion of the active cell. The cursor is then posi-
tioned after the new text. index can be a number, iinnsseerrtt or eenndd. pathName iinnsseerrtt ccoollss ?switches? index ?count? Inserts ccoouunntt cols starting at col iinnddeexx. If ccoouunntt is negative, it inserts before the specified col. Otherwise it inserts after the specified col. The selection willbe cleared. The switches are the same as those for col-
umn deletion. pathName iinnsseerrtt rroowwss ?switches? index ?count? Inserts ccoouunntt rows starting at row iinnddeexx. If ccoouunntt is negative, it inserts before the specified row. Otherwise it inserts after the specified row. The selection willbe cleared. The switches are the same as those for col-
umn deletion. pathName rreerreeaadd Rereads the old contents of the cell back into the editing buffer. Useful for a key binding whenis pressed to abort the edit (a default binding). pathName ssccaann option args This command is used to implement scanning on tables. It has two forms, depending on option: pathName ssccaann mmaarrkk x y Records x and y and the current view in the table window; used in conjunction with later ssccaann ddrraaggttoo commands. Typically this command is associated with a mouse button press in the widget. It returns an empty string. pathName ssccaann ddrraaggttoo x y. This command computes the difference between its x and y arguments and the x and y arguments to the last ssccaann mmaarrkk command for the widget. It then adjusts the view by 5 times the difference in coordinates. This command is typically associated with mouse motion events in the wid-
get, to produce the effect of dragging the list at high speed through the window. The return value is an empty string. pathName sseeee index Adjust the view in the table so that the cell given by index is positioned as the cell one off from top left (excluding title rows and columns) if the cell is not currently visible on the screen. The actual cell may be different to keep the screen full. pathName sseelleeccttiioonn option arg This command is used to adjust the selection within a table. It has several forms, depending on option: pathName sseelleeccttiioonn aanncchhoorr index Sets the selection anchor to the cell given by index. The selection anchor is the end of the selection that is fixed while dragging out a selection with the mouse. The index aanncchhoorr may be used to refer to the anchor cell. pathName sseelleeccttiioonn cclleeaarr first ?last? If any of the cells between first and last (inclusive) are selected, they are deselected. The selection state is not changed for cells outside this range. first may be specified as aallll to remove the selection from all cells. pathName sseelleeccttiioonn iinncclluuddeess index Returns 1 if the cell indicated by index is currently selected, 0 if it isn't. pathName sseelleeccttiioonn sseett first ?last? Selects all of the cells in the range between first and last, inclusive, without affecting the selection state of cells outside that range. pathName sseett ?row|col? index ?value? ?index value ...?Sets the specified index to the associated value. Table valida-
tion will not be triggered via this method. If rrooww or ccooll pre-
cedes the list of index/value pairs, then the value is assumed to be a Tcl list whose values will be split and set into the subsequent columns (if rrooww is specified) or rows (for ccooll). For example, sseett rrooww 22,,33 {{22,,33 22,,44 22,,55}} will set 3 cells, from 2,3 to2,5. The setting of cells is silently bounded by the known ta-
ble dimensions. pathName ssppaannss ?index? ?rows,cols index rows,cols ...? This command is used to manipulate row/col spans. When called with no arguments, all known spans are returned as a list of tuples of the form {index span}. When called with only theindex, the span for that index only is returned, if any. Other-
wise an even number of index rows,cols pairs are used to setspans. A span starts at the index and continues for the speci-
fied number of rows and cols. Negative spans are not supported.A span of 0,0 unsets any span on that cell. See EXAMPLES for
more info. pathName ttaagg option ?arg arg ...? This command is used to manipulate tags. The exact behavior of the command depends on the option argument that follows the ttaagg argument. cget, cell, and row|col complain about unknown tagnames. The following forms of the command are currently sup-
ported: pathName ttaagg cceellll tagName ?index ...? With no arguments, prints out the list of cells that use the tag. Otherwise it sets the specified cells to use the named tag, replacing any tag that may have been set using this method before. If tagName is {}, the cellsare reset to the default tag. Tags added during -*tag-
command evaluation do not register here. If tagName does not exist, it will be created with the default options. pathName ttaagg ccggeett tagName option This command returns the current value of the option named option associated with the tag given by tagName. Option may have any of the values accepted by the ttaagg ccoonnffiigguurree widget command. pathName ttaagg ccooll tagName ?col ...? With no arguments, prints out the list of cols that use the tag. Otherwise it sets the specified columns to use the named tag, replacing any tag that may have been set using this method before. If tagName is {}, the cols arereset to the default tag. Tags added during -coltagcom-
mand evaluation do not register here. If tagName does not exist, it will be created with the default options. pathName ttaagg ccoonnffiigguurree tagName ?option? ?value? ?option value ...? This command is similar to the ccoonnffiigguurree widget command except that it modifies options associated with the tag given by tagName instead of modifying options for the overall table widget. If no option is specified, the command returns a list describing all of the available options for tagName (see TTkkCCoonnffiigguurreeIInnffoo for information on the format of this list). If option is specified with no value, then the command returns a list describing theone named option (this list will be identical to the cor-
responding sublist of the value returned if no option isspecified). If one or more option-value pairs are speci-
fied, then the command modifies the given option(s) tohave the given value(s) in tagName; in this case the com-
mand returns an empty string. See TAGS above for details on the options available for tags. pathName ttaagg ddeelleettee tagName Deletes a tag. No error if the tag does not exist. pathName ttaagg eexxiissttss tagName Returns 1 if the named tag exists, 0 otherwise. pathName ttaagg iinncclluuddeess tagName index Returns 1 if the specified index has the named tag, 0 otherwise. pathName ttaagg lloowweerr tagName ?belowThis? Lower the priority of the named tag. If belowThis is notspecified, then the tag's priority is lowered to the bot-
tom, otherwise it is lowered to one below belowThis. pathName ttaagg nnaammeess ?pattern? If no pattern is specified, shows the names of all defined tags. Otherwise the pattern is used as a glob pattern to show only tags matching that pattern. Tag names are returned in priority order (highest priority tag first). pathName ttaagg rraaiissee tagName ?aboveThis? Raise the priority of the named tag. If aboveThis is not specified, then the tag's priority is raised to the top, otherwise it is raised to one above aboveThis. pathName ttaagg rrooww tagName ?row ...? With no arguments, prints out the list of rows that use the tag. Otherwise it sets the specified columns to use the named tag, replacing any tag that may have been set using this method before. If tagName is {}, the rows arereset to use the default tag. Tags added during -rowtag-
command evaluation do not register here. If tagName does not exist, it will be created with the default options. pathName vvaalliiddaattee index Explicitly validates the specified index based on the current-vvaalliiddaatteeccoommmmaanndd and returns 0 or 1 based on whether the cell
was validated. pathName wwiiddtthh ?col? ?value col value ...? If no col is specified, returns a list describing all cols for which a width has been set. If ccooll is specified with no value,it prints out the width of that col in characters (positive num-
ber) or pixels (negative number). If one or more col-value
pairs are specified, then it sets each col to be that width in characters (positive number) or pixels (negative number). If value is default, then the col uses the default width, specifiedby -ccoollwwiiddtthh.
pathName wwiinnddooww option ?arg arg ...? This command is used to manipulate embedded windows. The exactbehavior of the command depends on the option argument that fol-
lows the wwiinnddooww argument. The following forms of the command are currently supported: pathName wwiinnddooww ccggeett index option This command returns the current value of the option named option associated with the window given by index. Option may have any of the values accepted by the wwiinnddooww ccoonnffiigguurree widget command. pathName wwiinnddooww ccoonnffiigguurree index ?option? ?value? ?option value ...? This command is similar to the ccoonnffiigguurree widget command except that it modifies options associated with the embedded window given by index instead of modifying options for the overall table widget. If no option is specified, the command returns a list describing all of the available options for index (see TTkkCCoonnffiigguurreeIInnffoo for information on the format of this list). If option is specified with no value, then the command returns a listdescribing the one named option (this list will be iden-
tical to the corresponding sublist of the value returnedif no option is specified). If one or more option-value
pairs are specified, then the command modifies the given option(s) to have the given value(s) in index; in this case the command returns an empty string. See EMBEDDED WINDOWS above for details on the options available for windows. pathName wwiinnddooww ddeelleettee index ?index ...?Deletes an embedded window from the table. The associ-
ated window will also be deleted. pathName wwiinnddooww mmoovvee indexFrom indexTo Moves an embedded window from one cell to another. If a window already exists in the target cell, it will be deleted. pathName wwiinnddooww nnaammeess ?pattern?If no pattern is specified, shows the cells of all embed-
ded windows. Otherwise the pattern is used as a glob pattern to show only cells matching that pattern. pathName xxvviieeww 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 xxvviieeww Returns a list containing two elements. Each element is a real fraction between 0 and 1; together they describe the horizontal span that is visible in the window. Forexample, if the first element is .2 and the second ele-
ment is .6, 20% of the table's text is off-screen to the
left, the middle 40% is visible in the window, and 40% of
the text is off-screen to the right. These are the same
values passed to scrollbars via the -xxssccrroollllccoommmmaanndd
option. pathName xxvviieeww index Adjusts the view in the window so that the column given by index is displayed at the left edge of the window. pathName xxvviieeww mmoovveettoo fraction Adjusts the view in the window so that fraction of thetotal width of the table text is off-screen to the left.
fraction must be a fraction between 0 and 1. pathName xxvviieeww ssccrroollll number what This command shifts the view in the window left or right according to number and what. Number must be an integer. What must be either uunniittss or ppaaggeess or an abbreviation of one of these. If what is uunniittss, the view adjusts left or right by number cells on the display; if it is ppaaggeess thenthe view adjusts by number screenfuls. If number is neg-
ative then cells farther to the left become visible; if it is positive then cells farther to the right become visible. pathName yyvviieeww ?args? This command is used to query and change the vertical positionof the text in the widget's window. It can take any of the fol-
lowing forms: pathName yyvviieeww Returns a list containing two elements, both of which are real fractions between 0 and 1. The first element givesthe position of the table element at the top of the win-
dow, relative to the table as a whole (0.5 means it ishalfway through the table, for example). The second ele-
ment gives the position of the table element just after the last one in the window, relative to the table as a whole. These are the same values passed to scrollbarsvia the -yyssccrroollllccoommmmaanndd option.
pathName yyvviieeww index Adjusts the view in the window so that the row given by index is displayed at the top of the window. pathName yyvviieeww mmoovveettoo fraction Adjusts the view in the window so that the element given by fraction appears at the top of the window. Fraction is a fraction between 0 and 1; 0 indicates the first element in the table, 0.33 indicates the elementone-third the way through the table, and so on.
pathName yyvviieeww ssccrroollll number what This command adjusts the view in the window up or down according to number and what. Number must be an integer. What must be either uunniittss or ppaaggeess. If what is uunniittss, the view adjusts up or down by number cells; if it is ppaaggeess then the view adjusts by number screenfuls. If number is negative then earlier elements become visible; if it is positive then later elements become visible. DDEEFFAAUULLTT BBIINNDDIINNGGSS The initialization creates class bindings that give the following default behaviour:[1] Clicking Button-1 in a cell activates that cell. Clicking into
an already active cell moves the insertion cursor to the charac-
ter nearest the mouse.[2] Moving the mouse while Button-1 is pressed will stroke out a
selection area. Exiting while Button-1 is pressed causing scan-
ning to occur on the table along with selection.[3] Moving the mouse while Button-2 is pressed causes scanning to
occur without any selection. [4] Home moves the table to have the origin in view. [5] End moves the table to have the eenndd cell in view.[6] Control-Home moves the table to the origin and activates that
cell.[7] Control-End moves the table to the end and activates that cell.
[8] Shift-Control-Home extends the selection to the origin.
[9] Shift-Control-End extends the selection to the end.
[10] The left, right, up and down arrows move the active cell.[11] Shift-
extends the selection in that direction. [12] Control-leftarrow and Control-rightarrow move the insertion cur-
sor within the cell.[13] Control-slash selects all the cells.
[14] Control-backslash clears selection from all the cells.
[15] Backspace deletes the character before the insertion cursor in the active cell. [16] Delete deletes the character after the insertion cursor in the active cell. [17] Escape rereads the value of the active cell from the specified data source, discarding any edits that have may been performed on the cell.[18] Control-a moves the insertion cursor to the beginning of the
active cell.[19] Control-e moves the insertion cursor to the end of the active
cell.[20] Control-minus and Control-equals decrease and increase the width
of the column with the active cell in it.[21] Moving the mouse while Button-3 (the right button on Windows) is
pressed while you are over a border will cause interactive resizing of that row and/or column to occur, based on the valueof -rreessiizzeebboorrddeerrss.
Some bindings may have slightly different behavior dependent on the-sseelleeccttiioonnmmooddee of the widget.
If the widget is disabled using the -ssttaattee option, then its view can
still be adjusted and cells can still be selected, but no insertion cursor will be displayed and no cell modifications will take place. The behavior of tables can be changed by defining new bindings for individual widgets or by redefining the class bindings. The defaultbindings are either compiled in or read from a file expected to corre-
spond to: "[lindex $tclpkgPath 0]/Tktable
PPEERRFFOORRMMAANNCCEE IISSSSUUEESS/tkTable.tcl". The number of rows and columns or a table widget should not signifi-
cantly affect the speed of redraw. Recalculation and redraw of table parameters and cells is restricted as much as possible. The display cell with the insert cursor is redrawn each time the cursor blinks, which causes a steady stream of graphics traffic. Set the-iinnsseerrttooffffttiimmee option to 0 avoid this. The use of a -ccoommmmaanndd with the
table without a cache can cause significant slow-down, as the command
is called once for each request of a cell value. EEXXAAMMPPLLEESS Set the topleft title area to be one spanning cell. This overestimatesboth row and column span by one, but the command does all the con-
straining for us.$table span [$table cget -roworigin],[$table cget -colorigin] [$table cget -titlerows],[$table cget -titlecols]
Force a table window refresh (useful for the slight chance that a bug in the table is not causing proper refresh):$table configure -padx [$table cget -padx]
KKEEYYWWOORRDDSS table, widget, extension Tk 2.8 table(n)