1table(n) Tk Table Extension table(n)
2
3
4
5______________________________________________________________________________
6
8 table - Create and manipulate tables
9
11 table pathName ?options?
12
14 -anchor -background -cursor
15 -exportselection -font -foreground
16 -highlightbackground -highlightcolor -highlightthickness
17 -insertbackground -insertborderwidth-insertofftime
18 -insertontime -insertwidth -invertselected
19 -relief -takefocus -xscrollcommand
20 -yscrollcommand
21
22 See the options manual entry for details on the standard options.
23
24
26 [-autoclear autoClear] A boolean value which specifies whether the
27 first keypress in a cell will delete whatever text was previously
28 there. Defaults to 0. [-bordercursor borderCursor] Specifies the name
29 of the cursor to show when over borders, a visual indication that
30 interactive resizing is allowed (it is thus affect by the value of
31 -resizeborders). Defaults to crosshair. [-borderwidth or -bd border‐
32 Width] Specifies a non-negative pixel value or list of values indicat‐
33 ing the width of the 3-D border to draw on interior table cells (if
34 such a border is being drawn; the relief option typically determines
35 this). If one value is specified, a rectangle of this width will be
36 drawn. If two values are specified, then only the left and right edges
37 of the cell will have borders. If four values are specified, then the
38 values correspond to the {left right top bottom} edges. This can be
39 overridden by the a tag's borderwidth option. It can also be affected
40 by the defined -drawmode for the table. Each value in the list must
41 have one of the forms acceptable to Tk_GetPixels. [-browsecommand or
42 -browsecmd browseCommand] Specifies a command which will be evaluated
43 anytime the active cell changes. It uses the %-substition model
44 described in COMMAND SUBSTITUTION below. [-cache cache] A boolean
45 value that specifies whether an internal cache of the table contents
46 should be kept. This greatly enhances speed performance when used with
47 -command but uses extra memory. Can maintain state when both -command
48 and -variable are empty. The cache is automatically flushed whenever
49 the value of -cache or -variable changes, otherwise you have to explic‐
50 itly call clear on it. Defaults to off. [-colorigin colOrigin] Speci‐
51 fies what column index to interpret as the leftmost column in the ta‐
52 ble. This value is used for user indices in the table. Defaults to 0.
53 [-cols cols] Number of cols in the table. Defaults to 10. [-colsepa‐
54 rator colSeparator] Specifies a separator character that will be inter‐
55 preted as the column separator when cutting or pasting data in a table.
56 By default, columns are separated as elements of a tcl list. [-col‐
57 stretchmode colStretchMode] Specifies one of the following stretch
58 modes for columns to fill extra allocated window space:
59
60 none Columns will not stretch to fill the assigned window
61 space. If the columns are too narrow, there will be a
62 blank space at the right of the table. This is the
63 default.
64
65 unset Only columns that do not have a specific width set will
66 be stretched.
67
68 all All columns will be stretched by the same number of pix‐
69 els to fill the window space allocated to the table.
70 This mode can interfere with interactive border resizing
71 which tries to force column width.
72
73 last The last column will be stretched to fill the window
74 space allocated to the table.
75
76 fill (only valid for -rowstretch currently)
77 The table will get more or less columns according to the
78 window space allocated to the table. This mode has
79 numerous quirks and may disappear in the future.
80 [-coltagcommand colTagCommand] Provides the name of a procedure that
81 will be evaluated by the widget to determine the tag to be used for a
82 given column. When displaying a cell, the table widget will first
83 check to see if a tag has been defined using the tag col widget method.
84 If no tag is found, it will evaluate the named procedure passing the
85 column number in question as the sole argument. The procedure is
86 expected to return the name of a tag to use, or a null string. Errors
87 occuring during the evaluation of the procedure, or the return of an
88 invalid tag name are silently ignored. [-colwidth colWidth] Default
89 column width, interpreted as characters in the default font when the
90 number is positive, or pixels if it is negative. Defaults to 10.
91 [-command command] Specified a command to use as a procedural interface
92 to cell values. If -usecommand is true, this command will be used
93 instead of any reference to the -variable array. When retrieving cell
94 values, the return value of the command is used as the value for the
95 cell. It uses the %-substition model described in COMMAND SUBSTITUTION
96 below. [-drawmode drawMode] Sets the table drawing mode to one of the
97 following options:
98
99 slow The table is drawn to an offscreen pixmap using the Tk
100 bordering functions (double-buffering). This means there
101 will be no flashing, but this mode is slow for larger
102 tables.
103
104 compatible
105 The table is drawn directly to the screen using the Tk
106 border functions. It is faster, but the screen may flash
107 on update. This is the default.
108
109 fast The table is drawn directly to the screen and the borders
110 are done with fast X calls, so they are always one pixel
111 wide only. As a side effect, it restricts -borderwidth
112 to a range of 0 or 1. This mode provides best perfor‐
113 mance for large tables, but can flash on redraw and is
114 not 100% Tk compatible on the border mode.
115
116 single The table is drawn to the screen as in fast mode, but
117 only single pixel lines are drawn (not square borders).
118 [-ellipsis ellipsis] This specifies a string to display at the end of a
119 line that would be clipped by its cell, like ``...''. An ellipsis will
120 be displayed only on non-wrapping, non-multiline cells that would be
121 clipped. The ellipsis will display on the left for east anchored
122 cells, otherwise it displays on the right. Defaults to "" (no ellip‐
123 sis). [-flashmode flashMode] A boolean value which specifies whether
124 cells should flash when their value changes. The table tag flash will
125 be applied to these cells for the duration specified by -flashtime.
126 Defaults to 0. [-flashtime flashTime] The amount of time, in 1/4 sec‐
127 ond increments, for which a cell should flash when its value has
128 changed. -flashmode must be on. Defaults to 2. [-height height]
129 Specifies the desired height for the window, in rows. If zero or less,
130 then the desired height for the window is made just large enough to
131 hold all the rows in the table. The height can be further limited by
132 -maxheight. [-invertselected invertSelected] Specifies whether the
133 foreground and background of an item should simply have their values
134 swapped instead of merging the sel tag options when the cell is
135 selected. Defaults to 0 (merge sel tag). [-ipadx ipadX] A pixel value
136 specifying the internal offset X padding for text in a cell. This
137 value does not grow the size of the cell, it just causes the text to be
138 drawn further from the cell border. It only affects one side (depend‐
139 ing on anchor). Defaults to 0. See -padx for an alternate padding
140 style. [-ipady ipadY] A pixel value specifying the internal offset Y
141 padding for text in a cell. This value does not grow the size of the
142 cell, it just causes the text to be drawn further from the cell border.
143 It only affects one side (depending on anchor). Defaults to 0. See
144 -pady for an alternate padding style. [-justify justify] How to jus‐
145 tify multi-line text in a cell. It must be one of left, right, or cen‐
146 ter. Defaults to left. [-maxheight maxHeight] The max height in pix‐
147 els that the window will request. Defaults to 600.
148 [-maxwidth maxWidth] The max width in pixels that the window will
149 request. Defaults to 800. [-multiline multiline] Specifies the
150 default setting for the multiline tag option. Defaults to 1.
151 [-padx padX] A pixel value specifying the offset X padding for a cell.
152 This value causes the default size of the cell to increase by two times
153 the value (one for each side), unless a specific pixel size is chosen
154 for the cell with the width command. This will force an empty area on
155 the left and right of each cell edge. This padding affects all types
156 of data in the cell. Defaults to 0. See -ipadx for an alternate pad‐
157 ding style. [-pady padY] A pixel value specifying the offset Y padding
158 for a cell. This value causes the default size of the cell to increase
159 by two times the value (one for each side), unless a specific pixel
160 size is chosen for the cell with the height command. This will force
161 an empty area on the top and bottom of each cell edge. This padding
162 affects all types of data in the cell. Defaults to 0. See -ipadx for
163 an alternate padding style. [-resizeborders resizeBorders] Specifies
164 what kind of interactive border resizing to allow, must be one of row,
165 col, both (default) or none. [-rowheight rowHeight] Default row
166 height, interpreted as lines in the default font when the number is
167 positive, or pixels if it is negative. Defaults to 1. [-rowori‐
168 gin rowOrigin] Specifies what row index to interpret as the topmost row
169 in the table. This value is used for user indices in the table.
170 Defaults to 0. [-rows rows] Number of rows in the table. Defaults to
171 10. [-rowseparator rowSeparator] Specifies a separator character that
172 will be interpreted as the row separator when cutting or pasting data
173 in a table. By default, rows are separated as tcl lists. [-row‐
174 stretchmode rowStretchMode] Specifies the stretch modes for rows to
175 fill extra allocated window space. See -colstretchmode for valid
176 options. [-rowtagcommand rowTagCommand] Provides the name of a proce‐
177 dure that can evaluated by the widget to determine the tag to be used
178 for a given row. The procedure must be defined by the user to accept a
179 single argument (the row number), and return a tag name or null string.
180 This operates in a similar manner as -coltagcommand, except that it
181 applies to row tags. [-selectioncommand or -selcmd selectionCommand]
182 Specifies a command to evaluate when the selection is retrieved from a
183 table via the selection mechanism (ie: evaluating "selection get").
184 The return value from this command will become the string passed on by
185 the selection mechanism. It uses the %-substition model described in
186 COMMAND SUBSTITUTION below. If an error occurs, a Tcl background error
187 is generated and nothing is returned. [-selectmode selectMode] Speci‐
188 fies one of several styles for manipulating the selection. The value
189 of the option may be arbitrary, but the default bindings expect it to
190 be either single, browse, multiple, or extended; the default value is
191 browse. These styles are like those for the Tk listbox, except
192 expanded for 2 dimensions. [-selecttitle selectTitles] Specifies
193 whether title cells should be allowed in the selection. Defaults to 0
194 (disallowed). [-selecttype selectType] Specifies one of several types
195 of selection for the table. The value of the option may be one of row,
196 col, cell, or both (meaning row && col); the default value is cell.
197 These types define whether an entire row/col is affected when a cell's
198 selection is changed (set or clear). [-sparsearray sparseArray] A
199 boolean value that specifies whether an associated Tcl array should be
200 kept as a sparse array (1, the default) or as a full array (0). If
201 true, then cell values that are empty will be deleted from the array
202 (taking less memory). If false, then all values in the array will be
203 maintained. [-state state] Specifies one of two states for the entry:
204 normal or disabled. If the table is disabled then the value may not be
205 changed using widget commands and no insertion cursor will be dis‐
206 played, even if the input focus is in the widget. Also, all insert or
207 delete methods will be ignored. Defaults to normal.
208 [-titlecols titleCols] Number of columns to use as a title area.
209 Defaults to 0. [-titlerows titleRows] Number of rows to use as a title
210 area. Defaults to 0. [-usecommand useCommand] A boolean value which
211 specifies whether to use the command option. This value sets itself to
212 zero if command is used and returns an error. Defaults to 1 (will use
213 command if specified). [-validate validate] A boolean specifying
214 whether validation should occur for the active buffer. Defaults to 0.
215 [-validatecommand or -vcmd validateCommand] Specifies a command to exe‐
216 cute when the active cell is edited. This command is expected to
217 return a Tcl boolean. If it returns true, then it is assumed the new
218 value is OK, otherwise the new value is rejected (the edition will not
219 take place). Errors in this command are handled in the background. It
220 uses the %-substition model described in COMMAND SUBSTITUTION below.
221 [-variable variable] Global Tcl array variable to attach to the table's
222 C array. It will be created if it doesn't already exist or is a simple
223 variable. Keys used by the table in the array are of the form row,col
224 for cells and the special key active which contains the value of the
225 active cell buffer. The Tcl array is managed as a sparse array (the
226 table doesn't require all valid indices have values). No stored value
227 for an index is equivalent to the empty string, and clearing a cell
228 will remove that index from the Tcl array, unless the -sparsearray
229 options is set to 0. [-width width] Specifies the desired width for
230 the window, in columns. If zero or less, then the desired width for
231 the window is made just large enough to hold all the columns in the ta‐
232 ble. The width can be further limited by -maxwidth. [-wrap wrap]
233 Specifies the default wrap value for tags. Defaults to 0.
234_________________________________________________________________
235
236
238 The table command creates a 2-dimensional grid of cells. The table can
239 use a Tcl array variable or Tcl command for data storage and retrieval,
240 as well as optionally cache data in memory for speed. One of these
241 data sources must be configured before any data is retained by the ta‐
242 ble. The widget has an active cell, the contents of which can be
243 edited (when the state is normal). The widget supports a default style
244 for the cells and also multiple tags, which can be used to change the
245 style of a row, column or cell (see TAGS for details). A cell flash
246 can be set up so that changed cells will change color for a specified
247 amount of time ("blink"). Cells can have embedded images or windows,
248 as described in TAGS and "EMBEDDED WINDOWS" respectively.
249
250 One or more cells may be selected as described below. If a table is
251 exporting its selection (see -exportselection option), then it will
252 observe the standard X11 protocols for handling the selection. See THE
253 SELECTION for details.
254
255 It is not necessary for all the cells to be displayed in the table win‐
256 dow at once; commands described below may be used to change the view in
257 the window. Tables allow scrolling in both directions using the stan‐
258 dard -xscrollcommand and -yscrollcommand options. They also support
259 scanning, as described below.
260
261 In order to obtain good performance, the table widget supports multiple
262 drawing modes, two of which are fully Tk compatible.
263
264
266 When the table command is loaded into an interpreter, a built-in Tcl
267 command, tkTableInit, is evaluated. This will search for the appropri‐
268 ate table binding init file to load. The directories searched are
269 those in $tcl_pkgPath, both with Tktable(version) appended and without,
270 $tk_library and [pwd] (the current directory). You can also define an
271 $env(TK_TABLE_LIBRARY) to head this search list. By default, the file
272 searched for is called tkTable.tcl, but this can be overridden by set‐
273 ting $env(TK_TABLE_LIBRARY_FILE).
274
275 This entire init script can be overridden by providing your own
276 tkTableInit procedure before the library is loaded. Otherwise, the
277 aforementioned env(TK_TABLE_LIBRARY) variable will be set with the
278 directory in which $env(TK_TABLE_LIBRARY_FILE) was found.
279
280
282 Many of the widget commands for tables take one or more indices as
283 arguments. An index specifies a particular cell of the table, in any
284 of the following ways:
285
286 number,number
287 Specifies the cell as a numerical index of row,col which
288 corresponds to the index of the associated Tcl array, where
289 -roworigin,-colorigin corresponds to the first cell in the
290 table (0,0 by default). The values for row and column will
291 be constrained to actual values in the table, which means a
292 valid cell is always found.
293
294 active Indicates the cell that has the location cursor. It is
295 specified with the activate widget command.
296
297 anchor Indicates the anchor point for the selection, which is set
298 with the selection anchor widget command.
299
300 bottomright Indicates the bottom-rightmost cell visible in the table.
301
302 end Indicates the bottom right cell of the table.
303
304 origin Indicates the top-leftmost editable cell of the table, not
305 necessarily in the display. This takes into account the
306 user specified origin and title area.
307
308 topleft Indicates the top-leftmost editable cell visible in the ta‐
309 ble (this excludes title cells).
310
311 @x,y Indicates the cell that covers the point in the table win‐
312 dow specified by x and y (in pixel coordinates). If no
313 cell covers that point, then the closest cell to that point
314 is used.
315
316 In the widget command descriptions below, arguments named index, first,
317 and last always contain text indices in one of the above forms.
318
319
321 A tag is a textual string that is associated with zero or more rows,
322 columns or cells in a table. Tags may contain arbitrary characters,
323 but it is probably best to avoid using names which look like indices to
324 reduce coding confusion. A tag can apply to an entire row or column,
325 or just a single cell. There are several permanent tags in each table
326 that can be configured by the user and will determine the attributes
327 for special cells:
328
329 active This tag is given to the active cell
330
331 flash If flash mode is on, this tag is given to any recently
332 edited cells.
333
334 sel This tag is given to any selected cells.
335
336 title This tag is given to any cells in the title rows and
337 columns. This tag has -state disabled by default.
338
339 Tags control the way cells are displayed on the screen. Where appro‐
340 priate, the default for displaying cells is determined by the options
341 for the table widget. However, display options may be associated with
342 individual tags using the ``pathName tag configure'' widget command.
343 If a cell, row or column has been tagged, then the display options
344 associated with the tag override the default display style. The fol‐
345 lowing options are currently supported for tags:
346
347 -anchor anchor
348 Anchor for item in the cell space.
349
350 -background or -bg color
351 Background color of the cell.
352
353 -borderwidth or -bd pixelList
354 Borderwidth of the cell, of the same format for the ta‐
355 ble, but may also be empty to inherit the default table
356 borderwidth value (the default).
357
358 -ellipsis string
359 String to display at the end of a line that would be
360 clipped by its cell, like ``...''. An ellipsis will be
361 displayed only on non-wrapping, non-multiline cells that
362 would be clipped. The ellipsis will display on the left
363 for east anchored cells, otherwise it displays on the
364 right.
365
366 -font fontName
367 Font for text in the cell.
368
369 -foreground or -fg color
370 Foreground color of the cell.
371
372 -justify justify
373 How to justify multi-line text in a cell. It must be one
374 of left, right, or center.
375
376 -image imageName
377 An image to display in the cell instead of text.
378
379 -multiline boolean
380 Whether to display text with newlines on multiple lines.
381
382 -relief relief
383 The relief for the cell. May be the empty string to
384 cause this tag to not disturb the value.
385
386 -showtext boolean
387 Whether to show the text over an image.
388
389 -state state
390 The state of the cell, to allow for certain cells to be
391 disabled. This prevents the cell from being edited by
392 the insert or delete methods, but a direct set will not
393 be prevented.
394
395 -wrap boolean
396 Whether characters should wrap in a cell that is not wide
397 enough.
398
399 A priority order is defined among tags based on creation order (first
400 created tag has highest default priority), and this order is used in
401 implementing some of the tag-related functions described below. When a
402 cell is displayed, its properties are determined by the tags which are
403 assigned to it. The priority of a tag can be modified by the ``path‐
404 Name tag lower'' and ``pathName tag raise'' widget commands.
405
406 If a cell has several tags associated with it that define the same dis‐
407 play options (eg - a title cell with specific row and cell tags), then
408 the options of the highest priority tag are used. If a particular dis‐
409 play option hasn't been specified for a particular tag, or if it is
410 specified as an empty string, then that option will not be used; the
411 next-highest-priority tag's option will be used instead. If no tag
412 specifies a particular display option, then the default style for the
413 widget will be used.
414
415 Images are used for display purposes only. Editing in that cell will
416 still be enabled and any querying of the cell will show the text value
417 of the cell, regardless of the value of -showtext.
418
419
421 There may be any number of embedded windows in a table widget (one per
422 cell), and any widget may be used as an embedded window (subject to the
423 usual rules for geometry management, which require the table window to
424 be the parent of the embedded window or a descendant of its parent).
425 The embedded window's position on the screen will be updated as the ta‐
426 ble is modified or scrolled, and it will be mapped and unmapped as it
427 moves into and out of the visible area of the table widget. Each
428 embedded window occupies one cell's worth of space in the table widget,
429 and it is referred to by the index of the cell in the table. Windows
430 associated with the table widget are destroyed when the table widget is
431 destroyed.
432
433 Windows are used for display purposes only. A value still exists for
434 that cell, but will not be shown unless the window is deleted in some
435 way. If the window is destroyed or lost by the table widget to another
436 geometry manager, then any data associated with it is lost (the cell it
437 occupied will no longer appear in window names).
438
439 When an embedded window is added to a table widget with the window con‐
440 figure widget command, several configuration options may be associated
441 with it. These options may be modified with later calls to the window
442 configure widget command. The following options are currently sup‐
443 ported:
444
445 -create script
446 NOT CURRENTLY SUPPORTED. Specifies a Tcl script that may
447 be evaluated to create the window for the annotation. If
448 no -window option has been specified for this cell then
449 this script will be evaluated when the cell is about to
450 be displayed on the screen. Script must create a window
451 for the cell and return the name of that window as its
452 result. If the cell's window should ever be deleted, the
453 script will be evaluated again the next time the cell is
454 displayed.
455
456 -background or -bg color
457 Background color of the cell. If not specified, it uses
458 the table's default background.
459
460 -borderwidth or -bd pixelList
461 Borderwidth of the cell, of the same format for the ta‐
462 ble, but may also be empty to inherit the default table
463 borderwidth value (the default).
464
465 -padx pixels
466 As defined in the Tk options man page.
467
468 -pady pixels
469 As defined in the Tk options man page.
470
471 -relief relief
472 The relief to use for the cell in which the window lies.
473 If not specified, it uses the table's default relief.
474
475 -sticky sticky
476 Stickiness of the window inside the cell, as defined by
477 the grid command.
478
479 -window pathName
480 Specifies the name of a window (widget) to display in the
481 annotation. It must exist before being specified here.
482 When an empty string is specified, if a window was dis‐
483 played it will cease to be managed by the table widget.
484
485
487 Table selections are available as type STRING. By default, the value
488 of the selection will be the values of the selected cells in nested Tcl
489 list form where each row is a list and each column is an element of a
490 row list. You can change the way this value is interpreted by setting
491 the -rowseparator and -colseparator options. For example, default
492 Excel format would be to set -rowseparator to "\n" and -colseparator to
493 "\t". Changing these values affects both how the table sends out the
494 selection and reads in pasted data, ensuring that the table should
495 always be able to cut and paste to itself. It is possible to change
496 how pastes are handled by editing the table library procedure
497 tk_tablePasteHandler. This might be necessary if -selectioncommand is
498 set.
499
500
502 Individual cells can span multiple rows and/or columns. This is done
503 via the spans command (see below for exact arguments). Cells in the
504 title area that span are not permitted to span beyond the title area,
505 and will be constrained accordingly. If the title area shrinks during
506 a configure, sanity checking will occur to ensure the above. You may
507 set spans on regular cells that extend beyond the defined row/col area.
508 These spans will not be constrained, so that when the defined row/col
509 area expands, the span will expand with it.
510
511 When setting a span, checks are made as to whether the span would over‐
512 lap an already spanning or hidden cell. This is an error and it not
513 allowed. Spans can affect the overall speed of table drawing, although
514 not significantly. If spans are not used, then there is no performance
515 loss.
516
517 Cells hidden by spanning cells still have valid data. This will be
518 seen during cut and paste operations that involve hidden cells, or
519 through direct access by a command like get or set.
520
521 The drawing properties of spanning cells apply to only the visual area
522 of the cell. For example, if a cell is center justified over 5 col‐
523 umns, then when viewing any portion of those columns, it will appear
524 centered in the visible area. The non-visible column area will not be
525 considered in the centering calculations.
526
527
529 The various option based commands that the table supports all support
530 the familiar Tk %-substitution model (see bind for more details). The
531 following %-sequences are recognized and substituted by the table wid‐
532 get:
533
534 %c For SelectionCommand, it is the maximum number of columns in any
535 row in the selection. Otherwise it is the column of the triggered
536 cell.
537
538 %C A convenience substitution for %r,%c.
539
540 %i For SelectionCommand, it is the total number of cells in the
541 selection. For Command, it is 0 for a read (get) and 1 for a
542 write (set). Otherwise it is the current cursor position in the
543 cell.
544
545 %r For SelectionCommand, it is the number of rows in the selection.
546 Otherwise it is the row of the triggered cell.
547
548 %s For ValidateCommand, it is the current value of the cell being
549 validated. For SelectionCommand, it is the default value of the
550 selection. For BrowseCommand, it is the index of the last active
551 cell. For Command, it is empty for reads (get) and the current
552 value of the cell for writes (set).
553
554 %S For ValidateCommand, it is the potential new value of the cell
555 being validated. For BrowseCommand, it is the index of the new
556 active cell.
557
558 %W The pathname to the window for which the command was generated.
559
561 The table command creates a new Tcl command whose name is pathName.
562 This command may be used to invoke various operations on the widget.
563 It has the following general form:
564 pathName option ?arg arg ...?
565 Option and the args determine the exact behavior of the command.
566
567 The following commands are possible for table widgets:
568
569 pathName activate index
570 Sets the active cell to the one indicated by index.
571
572 pathName bbox first ?last?
573 It returns the bounding box for the specified cell (range) as a
574 4-tuple of x, y, width and height in pixels. It clips the box
575 to the visible portion, if any, otherwise an empty string is
576 returned.
577
578 pathName border option args
579 This command is a voodoo hack to implement border sizing for
580 tables. This is normally called through bindings, with the fol‐
581 lowing as valid options:
582
583 pathName border mark x y ?row|col?
584 Records x and y and the row and/or column border under
585 that point in the table window, if any; used in conjunc‐
586 tion with later border dragto commands. Typically this
587 command is associated with a mouse button press in the
588 widget. If row or col is not specified, it returns a
589 tuple of both border indices (an empty item means no bor‐
590 der). Otherwise, just the specified item is returned.
591
592 pathName border dragto x y
593 This command computes the difference between its x and y
594 arguments and the x and y arguments to the last border
595 mark command for the widget. It then adjusts the previ‐
596 ously marked border by the difference. This command is
597 typically associated with mouse motion events in the wid‐
598 get, to produce the effect of interactive border resiz‐
599 ing.
600
601 pathName cget option
602 Returns the current value of the configuration option given by
603 option. Option may have any of the values accepted by the table
604 command.
605
606 pathName clear option ?first? ?last?
607 This command is a convenience routine to clear certain state
608 information managed by the table. first and last represent
609 valid table indices. If neither are specified, then the command
610 operates on the whole table. The following options are recog‐
611 nized:
612
613 pathName clear cache ?first? ?last?
614 Clears the specified section of the cache, if the table
615 has been keeping one.
616
617 pathName clear sizes ?first? ?last?
618 Clears the specified row and column areas of specific
619 height/width dimensions. When just one index is speci‐
620 fied, for example 2,0, that is interpreted as row 2 and
621 column 0.
622
623 pathName clear tags ?first? ?last?
624 Clears the specified area of tags (all row, column and
625 cell tags).
626
627 pathName clear all ?first? ?last?
628 Performs all of the above clear functions on the speci‐
629 fied area.
630
631 pathName configure ?option? ?value option value ...?
632 Query or modify the configuration options of the widget. If no
633 option is specified, returns a list describing all of the avail‐
634 able options for pathName (see Tk_ConfigureInfo for information
635 on the format of this list). If option is specified with no
636 value, then the command returns a list describing the one named
637 option (this list will be identical to the corresponding sublist
638 of the value returned if no option is specified). If one or
639 more option-value pairs are specified, then the command modifies
640 the given widget option(s) to have the given value(s); in this
641 case the command returns an empty string. Option may have any
642 of the values accepted by the table command.
643
644 pathName curselection ?value?
645 With no arguments, it returns the sorted indices of the cur‐
646 rently selected cells. Otherwise it sets all the selected cells
647 to the given value. The set has no effect if there is no asso‐
648 ciated Tcl array or the state is disabled.
649
650 pathName curvalue ?value?
651 If no value is given, the value of the cell being edited
652 (indexed by active) is returned, else it is set to the given
653 value.
654
655 pathName delete option arg ?arg?
656 This command is used to delete various things in a table. It
657 has several forms, depending on the option:
658
659 pathName delete active index ?index?
660 Deletes text from the active cell. If only one index is
661 given, it deletes the character after that index, other‐
662 wise it deletes from the first index to the second.
663 index can be a number, insert or end.
664
665 pathName delete cols ?switches? index ?count?
666 Deletes count cols starting at (and including) col index.
667 The index will be constrained to the limits of the
668 tables. If count is negative, it deletes cols to the
669 left. Otherwise it deletes cols to the right. count
670 defaults to 1 (meaning just the column specified). At
671 the moment, spans are not adjusted with this action.
672 Optional switches are:
673
674 -holddimensions
675 Causes the table cols to be unaffected by the
676 deletion (empty cols may appear). By default the
677 dimensions are adjusted by count.
678
679 -holdselection
680 Causes the selection to be maintained on the abso‐
681 lute cells values. Otherwise, the selection will
682 be cleared..
683
684 -holdtags
685 Causes the tags specified by the tag method to not
686 move along with the data. Also prevents specific
687 widths set by the width method from being
688 adjusted. By default, these tags are properly
689 adjusted.
690
691 -holdwindows
692 Causes the embedded windows created with the win‐
693 dow method to not move along with the data. By
694 default, these windows are properly adjusted.
695
696 -keeptitles
697 Prevents title area cells from being changed.
698 Otherwise they are treated just like regular cells
699 and will move as specified.
700
701 -- Signifies the end of the switches.
702
703 pathName delete rows ?switches? index ?count?
704 Deletes count rows starting at (and including) row index.
705 If count is negative, it deletes rows going up. Other‐
706 wise it deletes rows going down. The selection will be
707 cleared. The switches are the same as those for column
708 deletion.
709
710 pathName get first ?last?
711 Returns the value of the cells specified by the table indices
712 first and (optionally) last in a list.
713
714 pathName height ?row? ?value row value ...?
715 If no row is specified, returns a list describing all rows for
716 which a height has been set. If row is specified with no value,
717 it prints out the height of that row in characters (positive
718 number) or pixels (negative number). If one or more row-value
719 pairs are specified, then it sets each row to be that height in
720 lines (positive number) or pixels (negative number). If value
721 is default, then the row uses the default height, specified by
722 -rowheight.
723
724 pathName hidden ?index? ?index ...?
725 When called without args, it returns all the hidden cells (those
726 cells covered by a spanning cell). If one index is specified,
727 it returns the spanning cell covering that index, if any. If
728 multiple indices are specified, it returns 1 if all indices are
729 hidden cells, 0 otherwise.
730
731 pathName icursor ?arg?
732 With no arguments, prints out the location of the insertion cur‐
733 sor in the active cell. With one argument, sets the cursor to
734 that point in the string. 0 is before the first character, you
735 can also use insert or end for the current insertion point or
736 the end of the text. If there is no active cell, or the cell or
737 table is disabled, this will return -1.
738
739 pathName index index ?row|col?
740 Returns the integer cell coordinate that corresponds to index in
741 the form row,col. If row or col is specified, then only the row
742 or column index is returned.
743
744 pathName insert option arg arg
745 This command is used to into various things into a table. It
746 has several forms, depending on the option:
747
748 pathName insert active index value
749 The value is a text string which is inserted at the index
750 postion of the active cell. The cursor is then posi‐
751 tioned after the new text. index can be a number, insert
752 or end.
753
754 pathName insert cols ?switches? index ?count?
755 Inserts count cols starting at col index. If count is
756 negative, it inserts before the specified col. Otherwise
757 it inserts after the specified col. The selection will
758 be cleared. The switches are the same as those for col‐
759 umn deletion.
760
761 pathName insert rows ?switches? index ?count?
762 Inserts count rows starting at row index. If count is
763 negative, it inserts before the specified row. Otherwise
764 it inserts after the specified row. The selection will
765 be cleared. The switches are the same as those for col‐
766 umn deletion.
767
768 pathName reread
769 Rereads the old contents of the cell back into the editing buf‐
770 fer. Useful for a key binding when <Escape> is pressed to abort
771 the edit (a default binding).
772
773 pathName scan option args
774 This command is used to implement scanning on tables. It has
775 two forms, depending on option:
776
777 pathName scan mark x y
778 Records x and y and the current view in the table window;
779 used in conjunction with later scan dragto commands.
780 Typically this command is associated with a mouse button
781 press in the widget. It returns an empty string.
782
783 pathName scan dragto x y.
784 This command computes the difference between its x and y
785 arguments and the x and y arguments to the last scan mark
786 command for the widget. It then adjusts the view by 5
787 times the difference in coordinates. This command is
788 typically associated with mouse motion events in the wid‐
789 get, to produce the effect of dragging the list at high
790 speed through the window. The return value is an empty
791 string.
792
793 pathName see index
794 Adjust the view in the table so that the cell given by index is
795 positioned as the cell one off from top left (excluding title
796 rows and columns) if the cell is not currently visible on the
797 screen. The actual cell may be different to keep the screen
798 full.
799
800 pathName selection option arg
801 This command is used to adjust the selection within a table. It
802 has several forms, depending on option:
803
804 pathName selection anchor index
805 Sets the selection anchor to the cell given by index.
806 The selection anchor is the end of the selection that is
807 fixed while dragging out a selection with the mouse. The
808 index anchor may be used to refer to the anchor cell.
809
810 pathName selection clear first ?last?
811 If any of the cells between first and last (inclusive)
812 are selected, they are deselected. The selection state
813 is not changed for cells outside this range. first may
814 be specified as all to remove the selection from all
815 cells.
816
817 pathName selection includes index
818 Returns 1 if the cell indicated by index is currently
819 selected, 0 if it isn't.
820
821 pathName selection set first ?last?
822 Selects all of the cells in the range between first and
823 last, inclusive, without affecting the selection state of
824 cells outside that range.
825
826 pathName set ?row|col? index ?value? ?index value ...?
827 Sets the specified index to the associated value. Table valida‐
828 tion will not be triggered via this method. If row or col pre‐
829 cedes the list of index/value pairs, then the value is assumed
830 to be a Tcl list whose values will be split and set into the
831 subsequent columns (if row is specified) or rows (for col). For
832 example, set row 2,3 {2,3 2,4 2,5} will set 3 cells, from 2,3 to
833 2,5. The setting of cells is silently bounded by the known ta‐
834 ble dimensions.
835
836 pathName spans ?index? ?rows,cols index rows,cols ...?
837 This command is used to manipulate row/col spans. When called
838 with no arguments, all known spans are returned as a list of
839 tuples of the form {index span}. When called with only the
840 index, the span for that index only is returned, if any. Other‐
841 wise an even number of index rows,cols pairs are used to set
842 spans. A span starts at the index and continues for the speci‐
843 fied number of rows and cols. Negative spans are not supported.
844 A span of 0,0 unsets any span on that cell. See EXAMPLES for
845 more info.
846
847 pathName tag option ?arg arg ...?
848 This command is used to manipulate tags. The exact behavior of
849 the command depends on the option argument that follows the tag
850 argument. cget, cell, and row|col complain about unknown tag
851 names. The following forms of the command are currently sup‐
852 ported:
853
854 pathName tag cell tagName ?index ...?
855 With no arguments, prints out the list of cells that use
856 the tag. Otherwise it sets the specified cells to use
857 the named tag, replacing any tag that may have been set
858 using this method before. If tagName is {}, the cells
859 are reset to the default tag. Tags added during -*tag‐
860 command evaluation do not register here. If tagName does
861 not exist, it will be created with the default options.
862
863 pathName tag cget tagName option
864 This command returns the current value of the option
865 named option associated with the tag given by tagName.
866 Option may have any of the values accepted by the tag
867 configure widget command.
868
869 pathName tag col tagName ?col ...?
870 With no arguments, prints out the list of cols that use
871 the tag. Otherwise it sets the specified columns to use
872 the named tag, replacing any tag that may have been set
873 using this method before. If tagName is {}, the cols are
874 reset to the default tag. Tags added during -coltagcom‐
875 mand evaluation do not register here. If tagName does
876 not exist, it will be created with the default options.
877
878 pathName tag configure tagName ?option? ?value? ?option value
879 ...?
880 This command is similar to the configure widget command
881 except that it modifies options associated with the tag
882 given by tagName instead of modifying options for the
883 overall table widget. If no option is specified, the
884 command returns a list describing all of the available
885 options for tagName (see Tk_ConfigureInfo for information
886 on the format of this list). If option is specified with
887 no value, then the command returns a list describing the
888 one named option (this list will be identical to the cor‐
889 responding sublist of the value returned if no option is
890 specified). If one or more option-value pairs are speci‐
891 fied, then the command modifies the given option(s) to
892 have the given value(s) in tagName; in this case the com‐
893 mand returns an empty string. See TAGS above for details
894 on the options available for tags.
895
896 pathName tag delete tagName
897 Deletes a tag. No error if the tag does not exist.
898
899 pathName tag exists tagName
900 Returns 1 if the named tag exists, 0 otherwise.
901
902 pathName tag includes tagName index
903 Returns 1 if the specified index has the named tag, 0
904 otherwise.
905
906 pathName tag lower tagName ?belowThis?
907 Lower the priority of the named tag. If belowThis is not
908 specified, then the tag's priority is lowered to the bot‐
909 tom, otherwise it is lowered to one below belowThis.
910
911 pathName tag names ?pattern?
912 If no pattern is specified, shows the names of all
913 defined tags. Otherwise the pattern is used as a glob
914 pattern to show only tags matching that pattern. Tag
915 names are returned in priority order (highest priority
916 tag first).
917
918 pathName tag raise tagName ?aboveThis?
919 Raise the priority of the named tag. If aboveThis is not
920 specified, then the tag's priority is raised to the top,
921 otherwise it is raised to one above aboveThis.
922
923 pathName tag row tagName ?row ...?
924 With no arguments, prints out the list of rows that use
925 the tag. Otherwise it sets the specified columns to use
926 the named tag, replacing any tag that may have been set
927 using this method before. If tagName is {}, the rows are
928 reset to use the default tag. Tags added during -rowtag‐
929 command evaluation do not register here. If tagName does
930 not exist, it will be created with the default options.
931
932 pathName validate index
933 Explicitly validates the specified index based on the current
934 -validatecommand and returns 0 or 1 based on whether the cell
935 was validated.
936
937 pathName width ?col? ?value col value ...?
938 If no col is specified, returns a list describing all cols for
939 which a width has been set. If col is specified with no value,
940 it prints out the width of that col in characters (positive num‐
941 ber) or pixels (negative number). If one or more col-value
942 pairs are specified, then it sets each col to be that width in
943 characters (positive number) or pixels (negative number). If
944 value is default, then the col uses the default width, specified
945 by -colwidth.
946
947 pathName window option ?arg arg ...?
948 This command is used to manipulate embedded windows. The exact
949 behavior of the command depends on the option argument that fol‐
950 lows the window argument. The following forms of the command
951 are currently supported:
952
953 pathName window cget index option
954 This command returns the current value of the option
955 named option associated with the window given by index.
956 Option may have any of the values accepted by the window
957 configure widget command.
958
959 pathName window configure index ?option? ?value? ?option value
960 ...?
961 This command is similar to the configure widget command
962 except that it modifies options associated with the
963 embedded window given by index instead of modifying
964 options for the overall table widget. If no option is
965 specified, the command returns a list describing all of
966 the available options for index (see Tk_ConfigureInfo for
967 information on the format of this list). If option is
968 specified with no value, then the command returns a list
969 describing the one named option (this list will be iden‐
970 tical to the corresponding sublist of the value returned
971 if no option is specified). If one or more option-value
972 pairs are specified, then the command modifies the given
973 option(s) to have the given value(s) in index; in this
974 case the command returns an empty string. See EMBEDDED
975 WINDOWS above for details on the options available for
976 windows.
977
978 pathName window delete index ?index ...?
979 Deletes an embedded window from the table. The associ‐
980 ated window will also be deleted.
981
982 pathName window move indexFrom indexTo
983 Moves an embedded window from one cell to another. If a
984 window already exists in the target cell, it will be
985 deleted.
986
987 pathName window names ?pattern?
988 If no pattern is specified, shows the cells of all embed‐
989 ded windows. Otherwise the pattern is used as a glob
990 pattern to show only cells matching that pattern.
991
992 pathName xview args
993 This command is used to query and change the horizontal position
994 of the information in the widget's window. It can take any of
995 the following forms:
996
997 pathName xview
998 Returns a list containing two elements. Each element is
999 a real fraction between 0 and 1; together they describe
1000 the horizontal span that is visible in the window. For
1001 example, if the first element is .2 and the second ele‐
1002 ment is .6, 20% of the table's text is off-screen to the
1003 left, the middle 40% is visible in the window, and 40% of
1004 the text is off-screen to the right. These are the same
1005 values passed to scrollbars via the -xscrollcommand
1006 option.
1007
1008 pathName xview index
1009 Adjusts the view in the window so that the column given
1010 by index is displayed at the left edge of the window.
1011
1012 pathName xview moveto fraction
1013 Adjusts the view in the window so that fraction of the
1014 total width of the table text is off-screen to the left.
1015 fraction must be a fraction between 0 and 1.
1016
1017 pathName xview scroll number what
1018 This command shifts the view in the window left or right
1019 according to number and what. Number must be an integer.
1020 What must be either units or pages or an abbreviation of
1021 one of these. If what is units, the view adjusts left or
1022 right by number cells on the display; if it is pages then
1023 the view adjusts by number screenfuls. If number is neg‐
1024 ative then cells farther to the left become visible; if
1025 it is positive then cells farther to the right become
1026 visible.
1027
1028 pathName yview ?args?
1029 This command is used to query and change the vertical position
1030 of the text in the widget's window. It can take any of the fol‐
1031 lowing forms:
1032
1033 pathName yview
1034 Returns a list containing two elements, both of which are
1035 real fractions between 0 and 1. The first element gives
1036 the position of the table element at the top of the win‐
1037 dow, relative to the table as a whole (0.5 means it is
1038 halfway through the table, for example). The second ele‐
1039 ment gives the position of the table element just after
1040 the last one in the window, relative to the table as a
1041 whole. These are the same values passed to scrollbars
1042 via the -yscrollcommand option.
1043
1044 pathName yview index
1045 Adjusts the view in the window so that the row given by
1046 index is displayed at the top of the window.
1047
1048 pathName yview moveto fraction
1049 Adjusts the view in the window so that the element given
1050 by fraction appears at the top of the window. Fraction
1051 is a fraction between 0 and 1; 0 indicates the first
1052 element in the table, 0.33 indicates the element
1053 one-third the way through the table, and so on.
1054
1055 pathName yview scroll number what
1056 This command adjusts the view in the window up or down
1057 according to number and what. Number must be an integer.
1058 What must be either units or pages. If what is units,
1059 the view adjusts up or down by number cells; if it is
1060 pages then the view adjusts by number screenfuls. If
1061 number is negative then earlier elements become visible;
1062 if it is positive then later elements become visible.
1063
1064
1066 The initialization creates class bindings that give the following
1067 default behaviour:
1068
1069 [1] Clicking Button-1 in a cell activates that cell. Clicking into
1070 an already active cell moves the insertion cursor to the charac‐
1071 ter nearest the mouse.
1072
1073 [2] Moving the mouse while Button-1 is pressed will stroke out a
1074 selection area. Exiting while Button-1 is pressed causing scan‐
1075 ning to occur on the table along with selection.
1076
1077 [3] Moving the mouse while Button-2 is pressed causes scanning to
1078 occur without any selection.
1079
1080 [4] Home moves the table to have the origin in view.
1081
1082 [5] End moves the table to have the end cell in view.
1083
1084 [6] Control-Home moves the table to the origin and activates that
1085 cell.
1086
1087 [7] Control-End moves the table to the end and activates that cell.
1088
1089 [8] Shift-Control-Home extends the selection to the origin.
1090
1091 [9] Shift-Control-End extends the selection to the end.
1092
1093 [10] The left, right, up and down arrows move the active cell.
1094
1095 [11] Shift-<arrow> extends the selection in that direction.
1096
1097 [12] Control-leftarrow and Control-rightarrow move the insertion cur‐
1098 sor within the cell.
1099
1100 [13] Control-slash selects all the cells.
1101
1102 [14] Control-backslash clears selection from all the cells.
1103
1104 [15] Backspace deletes the character before the insertion cursor in
1105 the active cell.
1106
1107 [16] Delete deletes the character after the insertion cursor in the
1108 active cell.
1109
1110 [17] Escape rereads the value of the active cell from the specified
1111 data source, discarding any edits that have may been performed
1112 on the cell.
1113
1114 [18] Control-a moves the insertion cursor to the beginning of the
1115 active cell.
1116
1117 [19] Control-e moves the insertion cursor to the end of the active
1118 cell.
1119
1120 [20] Control-minus and Control-equals decrease and increase the width
1121 of the column with the active cell in it.
1122
1123 [21] Moving the mouse while Button-3 (the right button on Windows) is
1124 pressed while you are over a border will cause interactive
1125 resizing of that row and/or column to occur, based on the value
1126 of -resizeborders.
1127
1128 Some bindings may have slightly different behavior dependent on the
1129 -selectionmode of the widget.
1130
1131 If the widget is disabled using the -state option, then its view can
1132 still be adjusted and cells can still be selected, but no insertion
1133 cursor will be displayed and no cell modifications will take place.
1134
1135 The behavior of tables can be changed by defining new bindings for
1136 individual widgets or by redefining the class bindings. The default
1137 bindings are either compiled in or read from a file expected to corre‐
1138 spond to: "[lindex $tcl_pkgPath 0]/Tktable<version>/tkTable.tcl".
1139
1140
1142 The number of rows and columns or a table widget should not signifi‐
1143 cantly affect the speed of redraw. Recalculation and redraw of table
1144 parameters and cells is restricted as much as possible.
1145
1146 The display cell with the insert cursor is redrawn each time the cursor
1147 blinks, which causes a steady stream of graphics traffic. Set the
1148 -insertofftime option to 0 avoid this. The use of a -command with the
1149 table without a cache can cause significant slow-down, as the command
1150 is called once for each request of a cell value.
1151
1152
1153
1155 Set the topleft title area to be one spanning cell. This overestimates
1156 both row and column span by one, but the command does all the con‐
1157 straining for us.
1158 $table span [$table cget -roworigin],[$table cget -colorigin] [$table cget -titlerows],[$table cget -titlecols]
1159 Force a table window refresh (useful for the slight chance that a bug
1160 in the table is not causing proper refresh):
1161 $table configure -padx [$table cget -padx]
1162
1163
1165 table, widget, extension
1166
1167
1168
1169Tk 2.8 table(n)