1TableMatrix(3)        User Contributed Perl Documentation       TableMatrix(3)
2
3
4

NAME

6       TableMatrix - Create and manipulate tables
7

Synopsis

9       $table = $parent->TableMatrix(?options?);
10

STANDARD OPTIONS

12       -anchor  -background  -cursor
13          -exportselection  -font  -foreground    -highlightbackground
14       -highlightcolor
15        -highlightthickness    -insertbackground  -insertborderwidth
16       -insertofftime
17          -insertontime  -insertwidth  -invertselected  -relief  -takefocus
18        -xscrollcommand    -yscrollcommand
19

Widget-specific Options

21       Switch: -autoclear
22       Name: autoClear
23       Class: AutoClear
24        A boolean value which specifies whether the first keypress in a cell
25        will delete whatever text was previously there.  Defaults to 0.
26
27       Switch:  -bordercursor
28       Name: borderCursor
29       Class: Cursor
30        Specifies the name of the cursor to show when over borders, a visual
31        indication that interactive resizing is allowed (it is thus affect by
32        the value of -resizeborders).  Defaults to crosshair.
33
34       Switch: -borderwidth or -bd
35       Name: borderWidth
36       Class: BorderWidth
37        Specifies a non-negative pixel value or list of values indicating the
38        width of the 3-D border to draw on interior table cells (if such a
39        border is being drawn; the <Brelief> option typically determines
40        this).  If one value is specified, a rectangle of this width will be
41        drawn.  If two values are specified, then only the left and right
42        edges of the cell will have borders.  If four values are specified,
43        then the values correspond to the {left right top bottom} edges.  This
44        can be overridden by the a tag's borderwidth option.  It can also be
45        affected by the defined -drawmode for the table.  Each value in the
46        list must have one of the forms acceptable to Tk_GetPixels.
47
48       Switch: -browsecommand or -browsecmd
49       Name: browseCommand
50       Class: BrowseCommand
51        Specifies a command (callback) which will be evaluated anytime the
52        active cell changes. The Previous Index and the Current index is
53        passed to this command as arguments.
54
55       Switch: -cache
56       Name: cache
57       Class: Cache
58        A boolean value that specifies whether an internal cache of the table
59        contents should be kept.  This greatly enhances speed performance when
60        used with -command but uses extra memory.  Can maintain state when
61        both -command and -variable are empty.  The cache is automatically
62        flushed whenever the value of -cache or -variable changes, otherwise
63        you have to explicitly call clear on it.  Defaults to off.
64
65       Switch: -colorigin
66       Name: colOrigin
67       Class: Origin
68        Specifies what column index to interpret as the leftmost column in the
69        table. This value is used for user indices in the table.  Defaults to
70        0.
71
72       Switch: -cols
73       Name: cols
74       Class: Cols
75        Number of cols in the table.  Defaults to 10.
76
77       Switch: -colseparator
78       Name: colSeparator
79       Class: Separator
80        Specifies a separator character that will be interpreted as the column
81        separator when cutting or pasting data in a table.  By default,
82        columns are separated as elements of a tcl list.
83
84       Switch: -colstretchmode
85       Name: colStretchMode
86       Class: StretchMode
87        Specifies one of the following stretch modes for columns to fill extra
88        allocated window space:
89
90       none
91         Columns will not stretch to fill the assigned window space.  If the
92         columns are too narrow, there will be a blank space at the right of
93         the table.  This is the default.
94
95       unset
96         Only columns that do not have a specific width set will be stretched.
97
98       all
99         All columns will be stretched by the same number of pixels to fill
100         the window space allocated to the table.  This mode can interfere
101         with interactive border resizing which tries to force column width.
102
103       last
104         The last column will be stretched to fill the window space allocated
105         to the table.
106
107       fill
108         (only valid for -rowstretch currently)
109
110         The table will get more or less columns according to the window space
111         allocated to the table.  This mode has numerous quirks and may
112         disappear in the future.
113
114       Switch: -coltagcommand
115       Name: colTagCommand
116       Class: TagCommand
117        Provides the name of a procedure that will be evaluated by the widget
118        to determine the tag to be used for a given column.  When displaying a
119        cell, the table widget will first check to see if a tag has been
120        defined using the tag col widget method.  If no tag is found, it will
121        evaluate the named procedure passing the column number in question as
122        the sole argument.  The procedure is expected to return the name of a
123        tag to use, or a null string. Errors occuring during the evaluation of
124        the procedure, or the return of an invalid tag name are silently
125        ignored.
126
127        The Current column number is passed as an argument to the col command.
128
129       Switch: -colwidth
130       Name: colWidth
131       Class: ColWidth
132        Default column width, interpreted as characters in the default font
133        when the number is positive, or pixels if it is negative.  Defaults to
134        10.
135
136       Switch: -command
137       Name: command
138       Class: Command
139        Specified a command to use as a procedural interface to cell values.
140        If -usecommand is true, this command will be used instead of any
141        reference to the -variable array.  When retrieving cell values, the
142        return value of the command is used as the value for the cell.
143
144        Args passed to this callback: The Set Flag (=1 if setting, else
145        retrieving), the current row, the current col, the cell value (if
146        setting).
147
148       Switch: -drawmode
149       Name: drawMode
150       Class: DrawMode
151        Sets the table drawing mode to one of the following options:
152
153       slow
154         The table is drawn to an offscreen pixmap using the Tk bordering
155         functions (double-buffering).  This means there will be no flashing,
156         but this mode is slow for larger tables.
157
158       compatible
159         The table is drawn directly to the screen using the Tk border
160         functions. It is faster, but the screen may flash on update.  This is
161         the default.
162
163       fast
164         The table is drawn directly to the screen and the borders are done
165         with fast X calls, so they are always one pixel wide only.  As a side
166         effect, it restricts -borderwidth to a range of 0 or 1.  This mode
167         provides best performance for large tables, but can flash on redraw
168         and is not 100% Tk compatible on the border mode.
169
170       single
171         The table is drawn to the screen as in fast mode, but only single
172         pixel lines are drawn (not square borders).
173
174       Switch: -flashmode
175       Name: flashMode
176       Class: FlashMode
177        A boolean value which specifies whether cells should flash when their
178        value changes.  The table tag flash will be applied to these cells for
179        the duration specified by -flashtime.  Defaults to 0.
180
181       Switch: -flashtime
182       Name: flashTime
183       Class: FlashTime
184        The amount of time, in 1/4 second increments, for which a cell should
185        flash when its value has changed.  -flashmode must be on.  Defaults to
186        2.
187
188       Switch: -height
189       Name: height
190       Class: Height
191        Specifies the desired height for the window, in rows. If zero or less,
192        then the desired height for the window is made just large enough to
193        hold all the rows in the table.  The height can be further limited by
194        -maxheight .
195
196       Switch: -invertselected
197       Name: invertSelected
198       Class: InvertSelected
199        Specifies whether the foreground and background of an item should
200        simply have their values swapped instead of merging the sel tag
201        options when the cell is selected.  Defaults to 0 (merge sel tag).
202
203       Switch: -ipadx
204       Name: ipadX
205       Class: Pad
206        A pixel value specifying the internal offset X padding for text in a
207        cell.  This value does not grow the size of the cell, it just causes
208        the text to be drawn further from the cell border.  It only affects
209        one side (depending on anchor).  Defaults to 0.  See -padx for an
210        alternate padding style.
211
212       Switch: -ipady
213       Name: ipadY
214       Class: Pad
215        A pixel value specifying the internal offset Y padding for text in a
216        cell.  This value does not grow the size of the cell, it just causes
217        the text to be drawn further from the cell border.  It only affects
218        one side (depending on anchor).  Defaults to 0.  See -pady for an
219        alternate padding style.
220
221       Switch: -justify
222       Name: justify
223       Class: Justify
224        How to justify multi-line text in a cell. It must be one of left,
225        right, or center. Defaults to left.
226
227       Switch: -maxheight
228       Name: maxHeight
229       Class: MaxHeight
230        The max height in pixels that the window will request.  Defaults to
231        600.
232
233       Switch: -maxwidth
234       Name: maxWidth
235       Class: MaxWidth
236        The max width in pixels that the window will request.  Defaults to
237        800.
238
239       Switch: -multiline
240       Name: multiline
241       Class: Multiline
242        Specifies the default setting for the multiline tag option.  Defaults
243        to 1.
244
245       Switch: -pady
246       Name: padX
247       Class: Pad
248        A pixel value specifying the offset X padding for a cell.  This value
249        causes the default size of the cell to increase by two times the value
250        (one for each side), unless a specific pixel size is chosen for the
251        cell with the width command.  This will force an empty area on the
252        left and right of each cell edge.  This padding affects all types of
253        data in the cell.  Defaults to 0.  See -ipadx for an alternate padding
254        style.
255
256       Switch: -pady
257       Name: padY
258       Class: Pad
259        A pixel value specifying the offset Y padding for a cell.  This value
260        causes the default size of the cell to increase by two times the value
261        (one for each side), unless a specific pixel size is chosen for the
262        cell with the height command.  This will force an empty area on the
263        top and bottom of each cell edge.  This padding affects all types of
264        data in the cell.  Defaults to 0.  See -ipadx for an alternate padding
265        style.
266
267       Switch: -resizeborders
268       Name: resizeBorders
269       Class: ResizeBorders
270        Specifies what kind of interactive border resizing to allow, must be
271        one of row, col, both (default) or none.
272
273       Switch: -rowheight
274       Name: rowHeight
275       Class:
276        RowHeight  Default row height, interpreted as lines in the default
277        font when the number is positive, or pixels if it is negative.
278        Defaults to 1.
279
280       Switch: -roworigin
281       Name: rowOrigin
282       Class: Origin
283        Specifies what row index to interpret as the topmost row in the table.
284        This value is used for user indices in the table.  Defaults to 0.
285
286       Switch: -rows
287       Name: rows
288       Class: Rows
289        Number of rows in the table.  Defaults to 10.
290
291       Switch: -rowseparator
292       Name: rowSeparator
293       Class: Separator
294        Specifies a separator character that will be interpreted as the row
295        separator when cutting or pasting data in a table.  By default, rows
296        are separated as tcl lists.
297
298       Switch: -rowstretchmode
299       Name: rowStretchMode
300       Class: StretchMode
301        Specifies the stretch modes for rows to fill extra allocated window
302        space.  See -colstretchmode for valid options.
303
304       Switch: -rowtagcommand
305       Name: rowTagCommand
306       Class: TagCommand
307        Provides the name of a procedure that can evaluated by the widget to
308        determine the tag to be used for a given row.  The procedure must be
309        defined by the user to accept a single argument (the row number), and
310        return a tag name or null string.  This operates in a similar manner
311        as -coltagcommand, except that it applies to row tags.
312
313        The Current row number is passed as an argument to the row command.
314
315       Switch: -selectioncommand or -selcmd
316       Name: selectionCommand
317       Class: SelectionCommand
318        Specifies a command (callback) to evaluate when the selection is
319        retrieved from a table via the selection mechanism (ie: evaluating
320        "selection get"). The return value from this command will become the
321        string passed on by the selection mechanism.  The following arguments
322        are passed to this callback: The number of rows in the selection,
323        number of columns in the selection, the selection string, the number
324        of cell in the selection.
325
326       Switch: -selectmode
327       Name: selectMode
328       Class: SelectMode
329        Specifies one of several styles for manipulating the selection.  The
330        value of the option may be arbitrary, but the default bindings expect
331        it to be either single, browse, multiple, or extended; the default
332        value is browse.  These styles are like those for the Tk listbox,
333        except expanded for 2 dimensions.
334
335       Switch: -selecttitle
336       Name: selectTitles
337       Class: SelectTitles
338        Specifies whether title cells should be allowed in the selection.
339        Defaults to 0 (disallowed).
340
341       Switch: -selecttype
342       Name: selectType
343       Class: SelectType
344        Specifies one of several types of selection for the table.  The value
345        of the option may be one of row, col, cell, or both (meaning row &&
346        col); the default value is cell.  These types define whether an entire
347        row/col is affected when a cell's selection is changed (set or clear).
348
349       Switch: -sparsearray
350       Name: sparseArray
351       Class: SparseArray
352        A boolean value that specifies whether an associated Tcl array should
353        be kept as a sparse array (1, the default) or as a full array (0).  If
354        true, then cell values that are empty will be deleted from the array
355        (taking less memory).  If false, then all values in the array will be
356        maintained.
357
358       Switch: -state
359       Name: state
360       Class: State
361        Specifies one of two states for the entry:  normal or disabled.  If
362        the table is disabled then the value may not be changed using widget
363        commands and no insertion cursor will be displayed, even if the input
364        focus is in the widget.  Also, all insert or delete methods will be
365        ignored.  Defaults to normal.
366
367       Switch: -titlecols
368       Name: titleCols
369       Class: TitleCols
370        Number of columns to use as a title area.  Defaults to 0.
371
372       Switch: -titlerows
373       Name: titleRows
374       Class: TitleRows
375        Number of rows to use as a title area.  Defaults to 0.
376
377       Switch: -usecommand
378       Name: useCommand
379       Class: UseCommand
380        A boolean value which specifies whether to use the command option.
381        This value sets itself to zero if command is used and returns an
382        error. Defaults to 1 (will use command if specified).
383
384       Switch: -validate
385       Name: validate
386       Class: Validate
387        A boolean specifying whether validation should occur for the active
388        buffer. Defaults to 0.
389
390       Switch: -validatecommand or -vcmd
391       Name: validateCommand
392       Class: ValidateCommand
393        Specifies a command (callback) to execute when the active cell is
394        edited.  This command is expected to return a 1 or 0.  If it returns
395        1, then it is assumed the new value is OK, otherwise the new value is
396        rejected (the edition will not take place).  Errors in this command
397        are handled in the background. The following arguments are supplied to
398        the callback: row, col, oldContents of cell, potential new contents of
399        cell, Current Index in the cell.
400
401       Switch: -variable
402       Name: variable
403       Class: Variable
404        Global Tcl array variable to attach to the table's C array.  It will
405        be created if it doesn't already exist or is a simple variable.  Keys
406        used by the table in the array are of the form row,col for cells and
407        the special key active which contains the value of the active cell
408        buffer.  The Tcl array is managed as a sparse array (the table doesn't
409        require all valid indices have values).  No stored value for an index
410        is equivalent to the empty string, and clearing a cell will remove
411        that index from the Tcl array, unless the -sparsearray options is set
412        to 0.
413
414       Switch: -width
415       Name: width
416       Class: Width
417        Specifies the desired width for the window, in columns. If zero or
418        less, then the desired width for the window is made just large enough
419        to hold all the columns in the table.  The width can be further
420        limited by -maxwidth.
421
422       Switch: -wrap
423       Name: wrap
424       Class: Wrap
425        Specifies the default wrap value for tags.  Defaults to 0.
426

DESCRIPTION

428       The TableMatrix command creates a 2-dimensional grid of cells.  The
429       table can use a Tcl array variable or Tcl command for data storage and
430       retrieval.  The widget has an active cell, the contents of which can be
431       edited (when the state is normal).  The widget supports a default style
432       for the cells and also multiple tags, which can be used to change the
433       style of a row, column or cell (see TAGS for details).  A cell flash
434       can be set up so that changed cells will change color for a specified
435       amount of time ("blink").
436        Cells can have embedded images or windows, as described in Tags and
437       "Embedded Windows" respectively.
438
439       One or more cells may be selected as described below.
440        If a table is exporting its selection (see -exportselection option),
441       then it will observe the standard X11 protocols for handling the
442       selection.
443        See "the Selection" for details. It is not necessary for all the cells
444       to be displayed in the table window at once; commands described below
445       may be used to change the view in the window. Tables allow scrolling in
446       both directions using the standard -xscrollcommand and -yscrollcommand
447       options.
448        They also support scanning, as described below.
449
450       In order to obtain good performance, the table widget supports multiple
451       drawing modes, two of which are fully Tk compatible.
452

Indices

454       Many of the widget commands for tables take one or more indices as
455       arguments. An index specifies a particular cell of the table, in any of
456       the following ways:
457
458       number,number
459        Specifies the cell as a numerical index of row,col which corresponds
460        to the index of the associated Perl Hash, where -roworigin,-colorigin
461        corresponds to the first cell in the table (0,0 by default). The
462        values for row and column will be constrained to actual values in the
463        table, which means a valid cell is always found.
464
465       active
466        Indicates the cell that has the location cursor. It is specified with
467        the activate widget command.
468
469       anchor
470        Indicates the anchor point for the selection, which is set with the
471        selection anchor widget command.
472
473       bottomright
474        Indicates the bottom-rightmost cell visible in the table.
475
476       end
477        Indicates the bottom right cell of the table.
478
479       origin
480        Indicates the top-leftmost editable cell of the table, not necessarily
481        in the display.  This takes into account the user specified origin and
482        title area.
483
484       topleft
485        Indicates the top-leftmost editable cell visible in the table (this
486        excludes title cells).
487
488       @x,y
489        Indicates the cell that covers the point in the table window specified
490        by x and y (in pixel coordinates).  If no cell covers that point, then
491        the closest cell to that point is used. In the widget command
492        descriptions below, arguments named index, first, and last always
493        contain text indices in one of the above forms.
494

Tags

496       A tag is a textual string that is associated with zero or more rows,
497       columns or cells in a table.  Tags may contain arbitrary characters,
498       but it is probably best to avoid using names which look like indices to
499       reduce coding confusion.  There may be any number of tags in a table,
500       but each row, column or cell can only have one tag associated with it
501       at a time.  There are several permanent tags in each table that can be
502       configured by the user and will determine the attributes for special
503       cells:
504
505       active
506        This tag is given to the active cell
507
508       flash
509        If flash mode is on, this tag is given to any recently edited cells.
510
511       sel
512        This tag is given to any selected cells.
513
514       title
515        This tag is given to any cells in the title rows and columns.  This
516        tag has -state disabled by default.
517
518       Tags control the way cells are displayed on the screen.  Where
519       appropriate, the default for displaying cells is determined by the
520       options for the table widget.  However, display options may be
521       associated with individual tags using the tagConfigure method.  If a
522       cell, row or column has been tagged, then the display options
523       associated with the tag override the default display style.  The
524       following options are currently supported for tags:
525
526       -anchor anchor
527        Anchor for item in the cell space.
528
529       -background or -bg color
530        Background color of the cell.
531
532       -borderwidth or -bd pixel
533        Borderwidth of the cell, of the same format for the table, but may
534        also be empty to inherit the default table borderwidth value (the
535        default).
536
537       -font fontName
538        Font for text in the cell.
539
540       -foreground or -fg color
541        Foreground color of the cell.
542
543       -justify justify
544        How to justify multi-line text in a cell. It must be one of left,
545        right, or center.
546
547       -image imageName
548        An image to display in the cell instead of text.
549
550       -multiline boolean
551        Whether to display text with newlines on multiple lines.
552
553       -relief
554        The relief for the cell. May be the empty string to cause this tag to
555        not disturb the value.
556
557       -showtext boolean
558        Whether to show the text over an image.
559
560       -state state
561        The state of the cell, to allow for certain cells to be disabled. This
562        prevents the cell from being edited by the insert  or delete methods,
563        but a direct set will not be prevented.
564
565       -wrap boolean
566        Whether characters should wrap in a cell that is not wide enough.
567
568       A priority order is defined among tags based on creation order (first
569       created tag has highest default priority), and this order is used in
570       implementing some of the tag-related functions described below.  When a
571       cell is displayed, its properties are determined by the tags which are
572       assigned to it.  The priority of a tag can be modified by the tagLower
573       and the tagRaise methods.
574
575       If a cell has several tags associated with it that define the same
576       display options (eg - a title cell with specific row and cell tags),
577       then the options of the highest priority tag are used.  If a particular
578       display option hasn't been specified for a particular tag, or if it is
579       specified as an empty string, then that option will not be used; the
580       next-highest-priority tag's option will be used instead.  If no tag
581       specifies a particular display option, then the default style for the
582       widget will be used.
583
584       Images are used for display purposes only.  Editing in that cell will
585       still be enabled and any querying of the cell will show the text value
586       of the cell, regardless of the value of -showtext.
587
588       Note: There can be only one tag for a given tag type. ( Tag types =
589       flash, active, sel, title, celltag rowtag, coltag.) For example, you
590       can't apply two cell tags to a single cell (or two row tags to a single
591       row, etc) and expect the tag's properties to be merged. The last tag-
592       type applied will be the one that is used.
593

Embedded Windows

595       There may be any number of embedded windows in a table widget (one per
596       cell), and any widget may be used as an embedded window (subject to the
597       usual rules for geometry management, which require the table window to
598       be the parent of the embedded window or a descendant of its parent).
599       The embedded window's position on the screen will be updated as the
600       table is modified or scrolled, and it will be mapped and unmapped as it
601       moves into and out of the visible area of the table widget.  Each
602       embedded window occupies one cell's worth of space in the table widget,
603       and it is referred to by the index of the cell in the table.  Windows
604       associated with the table widget are destroyed when the table widget is
605       destroyed.
606
607       Windows are used for display purposes only.  A value still exists for
608       that cell, but will not be shown unless the window is deleted in some
609       way.  If the window is destroyed or lost by the table widget to another
610       geometry manager, then any data associated with it is lost (the cell it
611       occupied will no longer appear in window names).
612
613       When an embedded window is added to a table widget with the window
614       configure widget command, several configuration options may be
615       associated with it.  These options may be modified with later calls to
616       the window configure widget command.  The following options are
617       currently supported:
618
619       -create callback
620        NOT CURRENTLY SUPPORTED.  Specifies a Tcl script that may be evaluated
621        to create the window for the annotation.
622         If no -window option has been specified for this cell then this
623        script will be evaluated when the cell is about to be displayed on the
624        screen.
625         Script must create a window for the cell and return the name of that
626        window as its result. If the cell's window should ever be deleted, the
627        script will be evaluated again the next time the cell is displayed.
628
629       -background or -bg color
630        Background color of the cell.  If not specified, it uses the table's
631        default background.
632
633       -borderwidth or -bd pixelList
634        Borderwidth of the cell, of the same format for the table, but may
635        also be empty to inherit the default table borderwidth value (the
636        default).
637
638       -padx pixels
639        As defined in the Tk options man page.
640
641       -pady pixels
642        As defined in the Tk options man page.
643
644       -relief relief
645        The relief to use for the cell in which the window lies.  If not
646        specified, it uses the table's default relief.
647
648       -sticky sticky
649        Stickiness of the window inside the cell, as defined by the grid
650        command.
651
652       -window $widget
653        Specifies the a window to display in the  annotation.  It must exist
654        before being specified here.
655

the Selection

657       Table selections are available as type STRING.  By default, the value
658       of the selection will be the values of the selected cells in nested Tcl
659       list form where each row is a list and each column is an element of a
660       row list. You can change the way this value is interpreted by setting
661       the -rowseparator and -colseparator options.
662        For example, default Excel format would be to set -rowseparator to
663       "\n" and -colseparator to "\t".  Changing these values affects both how
664       the table sends out the selection and reads in pasted data, ensuring
665       that the table should always be able to cut and paste to itself.  It is
666       possible to change how pastes are handled by editing the table library
667       procedure tk_tablePasteHandler .  This might be necessary if
668       -selectioncommand is set.
669

Row/Col Spanning

671       Individual cells can span multiple rows and/or columns.  This is done
672       via the spans command (see below for exact arguments).  Cells in the
673       title area that span are not permitted to span beyond the title area,
674       and will be constrained accordingly.  If the title area shrinks during
675       a configure, sanity checking will occur to ensure the above.  You may
676       set spans on regular cells that extend beyond the defined row/col area.
677       These spans will not be constrained, so that when the defined row/col
678       area expands, the span will expand with it.
679
680       When setting a span, checks are made as to whether the span would
681       overlap an already spanning or hidden cell.  This is an error and it
682       not allowed. Spans can affect the overall speed of table drawing,
683       although not significantly.  If spans are not used, then there is no
684       performance loss.
685
686       Cells hidden by spanning cells still have valid data.  This will be
687       seen during cut and paste operations that involve hidden cells, or
688       through direct access by a command like get or set.
689
690       The drawing properties of spanning cells apply to only the visual area
691       of the cell.  For example, if a cell is center justified over 5
692       columns, then when viewing any portion of those columns, it will appear
693       centered in the visible area. The non-visible column area will not be
694       considered in the centering calculations.
695

Command Substitution

697       The various option based commands that the table supports all support
698       the familiar Tk %-substitution model (see Tk::bind for more details).
699        The following %-sequences are recognized and substituted by the table
700       widget:
701
702       %c
703        For SelectionCommand, it is the maximum number of columns in any row
704        in the selection.  Otherwise it is the column of the triggered cell.
705
706       %C
707        A convenience substitution for %r,%c.
708
709       %i
710        For SelectionCommand, it is the total number of cells in the
711        selection. For Command, it is 0 for a read (get) and 1 for a write
712        (set). Otherwise it is the current cursor position in the cell.
713
714       %r
715        For SelectionCommand, it is the number of rows in the selection.
716        Otherwise it is the row of the triggered cell.
717
718       %s
719        For ValidateCommand, it is the current value of the cell being
720        validated.  For SelectionCommand, it is the default value of the
721        selection. For BrowseCommand , it is the index of the last active
722        cell. For Command, it is empty for reads (get) and the current value
723        of the cell for writes (set).
724
725       %S
726        For ValidateCommand, it is the potential new value of the cell being
727        validated.  For BrowseCommand, it is the index of the new active cell.
728
729       %W
730        The pathname to the window for which the command was generated.
731

Widget Methods

733       The $window->TableMatrix method creates a widget object. This object
734       supports the configure and cget methods described in Tk::options which
735       can be used to enquire and modify the options described above.  The
736       widget also inherits all the methods provided by the generic Tk::Widget
737       class.
738
739       The following additional methods are available for scale widgets:
740
741       $table->activate(index)
742        Sets the active cell to the one indicated by index.
743
744       $table->bbox(first, ?last?)
745        It returns the bounding box for the specified cell (range) as a
746        4-tuple of x, y, width and height in pixels.  It clips the box to the
747        visible portion, if any, otherwise an empty string is returned.
748
749       $table->border(option, args)
750        This command is a voodoo hack to implement border sizing for tables.
751        This is normally called through bindings, with the following as valid
752        options:
753
754       $table->borderMark(x, y, ?row|col?)
755         Records x and y and the row and/or column border under that point in
756         the table window, if any; used in conjunction with later border
757         dragto commands.  Typically this command is associated with a mouse
758         button press in the widget.  If row or col is not specified, it
759         returns a tuple of both border indices (an empty item means no
760         border). Otherwise, just the specified item is returned.
761
762       $table->borderDragto(x, y)
763         This command computes the difference between its x and y arguments
764         and the x and y arguments to the last border mark command for the
765         widget.  It then adjusts the previously marked border by the
766         difference.  This command is typically associated with mouse motion
767         events in the widget, to produce the effect of interactive border
768         resizing.
769
770       $table->cget(option)
771        Returns the current value of the configuration option given by option.
772        Option may have any of the values accepted by the table command.
773
774       $table->clear(option, ?first?, ?last?)
775        This command is a convenience routine to clear certain state
776        information managed by the table.  first and last represent valid
777        table indices.  If neither are specified, then the command operates on
778        the whole table.  The following options are recognized:
779
780       $table->clearCache(?first?, ?last?)
781         Clears the specified section of the cache, if the table has been
782         keeping one.
783
784       $table->clearSizes(?first?, ?last?)
785         Clears the specified row and column areas of specific height/width
786         dimensions.  When just one index is specified, for example 2,0, that
787         is interpreted as row 2 and column 0.
788
789       $table->clearTags(?first?, ?last?)
790         Clears the specified area of tags (all row, column and cell tags).
791
792       $table->clearAll(?first?, ?last?)
793         Performs all of the above clear functions on the specified area.
794
795       $table->colWidth(?col?, ?value, col, value, ...?)
796        If no col is specified, returns a list describing all cols for which a
797        width has been set.  If col is specified with no value, it prints out
798        the width of that col in characters (positive number) or pixels
799        (negative number).  If one or more col-value pairs are specified, then
800        it sets each col to be that width in characters (positive number) or
801        pixels (negative number).  If value is default, then the col uses the
802        default width, specified by -colwidth.
803
804        $table->configure(?option?, ?value, option, value, ...?)
805         Query or modify the configuration options of the widget. If no option
806         is specified, returns a list describing all of the available options
807         for pathName (see Tk_ConfigureInfo for information on the format of
808         this list).  If option is specified with no value, then the command
809         returns a list describing the one named option (this list will be
810         identical to the corresponding sublist of the value returned if no
811         option is specified).  If one or more option-value pairs are
812         specified, then the command modifies the given widget option(s) to
813         have the given value(s);  in this case the command returns an empty
814         string. Option may have any of the values accepted by the table
815         command.
816
817        $table->curselection(?value?)
818         With no arguments, it returns the sorted indices of the currently
819         selected cells.  Otherwise it sets all the selected cells to the
820         given value.  The set has no effect if there is no associated Tcl
821         array or the state is disabled.
822
823        $table->curvalue(?value?)
824         If no value is given, the value of the cell being edited (indexed by
825         active) is returned, else it is set to the given value.
826
827        $table->delete(option, arg, ?arg?)
828         This command is used to delete various things in a table.  It has
829         several forms, depending on the option:
830
831        $table->deleteActive(index, ?index?)
832          Deletes text from the active cell.  If only one index is given, it
833          deletes the character after that index, otherwise it deletes from
834          the first index to the second.  index can be a number, insert or
835          end.
836
837        $table->deleteCols(?switches?, index, ?count?)
838          Deletes count cols starting at (and including) col index.  The index
839          will be constrained to the limits of the tables.  If count is
840          negative, it deletes cols to the left.  Otherwise it deletes cols to
841          the right.  count defaults to 1 (meaning just the column specified).
842          The selection will be cleared.  At the moment, spans are not
843          adjusted with this action.  Optional switches are:
844
845        -holddimensions
846           Causes the table cols to be unaffected by the deletion (empty cols
847           may appear).
848            By default the dimensions are adjusted by count.
849
850        -holdtags
851           Causes the tags specified by the tag method to not move along with
852           the data.  Also prevents specific widths set by the width method
853           from being adjusted.
854            By default, these tags are properly adjusted.
855
856        -holdwindows
857           Causes the embedded windows created with the window method to not
858           move along with the data.  By default, these windows are properly
859           adjusted.
860
861        -keeptitles
862           Prevents title area cells from being changed.  Otherwise they are
863           treated just like regular cells and will move as specified.
864
865        $table->deleteRows(?switches?, index, ?count?)
866          Deletes count rows starting at (and including) row index.  If count
867          is negative, it deletes rows going up.  Otherwise it deletes rows
868          going down.  The selection will be cleared.  The switches are the
869          same as those for column deletion.
870
871        $table->get(first, ?last?)
872         Returns the value of the cells specified by the table indices first
873         and (optionally) last in a list.
874
875        $table->hidden(?index?, ?index, ...?)
876         When called without args, it returns all the hidden cells (those
877         cells covered by a spanning cell).  If one index is specified, it
878         returns the spanning cell covering that index, if any.  If multiple
879         indices are specified, it returns 1 if all indices are hidden cells,
880         0 otherwise.
881
882        $table->icursor(?arg?)
883         With no arguments, prints out the location of the insertion cursor in
884         the active cell.  With one argument, sets the cursor to that point in
885         the string.  0 is before the first character, you can also use insert
886         or end for the current insertion point or the end of the text.  If
887         there is no active cell, or the cell or table is disabled, this will
888         return -1.
889
890        $table->index(index, ?row|col?)
891         Returns the integer cell coordinate that corresponds to index in the
892         form row,col.  If row  or col is specified, then only the row or
893         column index is returned.
894
895        $table->insert(option, arg, arg)
896         This command is used to into various things into a table.  It has
897         several forms, depending on the option:
898
899        $table->insertActive(index, value)
900          The value is a text string which is inserted at the index postion of
901          the active cell.  The cursor is then positioned after the new text.
902          index can be a number, insert or end.
903
904        $table->insertCols(?switches?, index, ?count?)
905          Inserts count cols starting at col index.  If count is negative, it
906          inserts before the specified col.  Otherwise it inserts after the
907          specified col.  The selection will be cleared.  The switches are the
908          same as those for column deletion.
909
910        $table->insertRows(?switches?, index, ?count?)
911          Inserts count rows starting at row index.  If count is negative, it
912          inserts before the specified row.  Otherwise it inserts after the
913          specified row.  The selection will be cleared.  The switches are the
914          same as those for column deletion.
915
916        $table->reread()
917         Rereads the old contents of the cell back into the editing buffer.
918         Useful for a key binding when <Escape> is pressed to abort the edit
919         (a default binding).
920
921        $table->rowHeight(?row?, ?value, row, value, ...?)
922         If no row is specified, returns a list describing all rows for which
923         a height has been set.  If row is specified with no value, it prints
924         out the height of that row in characters (positive number) or pixels
925         (negative number).  If one or more row-value pairs are specified,
926         then it sets each row to be that height in lines (positive number) or
927         pixels (negative number).  If value is default, then the row uses the
928         default height, specified by -rowheight.
929
930        $table->scan(option, args)
931         This command is used to implement scanning on tables.  It has two
932         forms, depending on option:
933
934        $table->scanMark(x, y)
935          Records x and y and the current view in the table window;
936           used in conjunction with later scan dragto commands. Typically this
937          command is associated with a mouse button press in the widget.  It
938          returns an empty string.
939
940        $table->scanDragto(x, y.)
941          This command computes the difference between its x and y arguments
942          and the x and y arguments to the last scan mark command for the
943          widget.  It then adjusts the view by 5 times the difference in
944          coordinates.  This command is typically associated with mouse motion
945          events in the widget, to produce the effect of dragging the list at
946          high speed through the window.  The return value is an empty string.
947
948        $table->see(index)
949         Adjust the view in the table so that the cell given by index is
950         positioned as the cell one off from top left (excluding title rows
951         and columns) if the cell is not currently visible on the screen.  The
952         actual cell may be different to keep the screen full.
953
954        $table->selection(option, arg)
955         This command is used to adjust the selection within a table.
956          It has several forms, depending on option:
957
958        $table->selectionAnchor(index)
959          Sets the selection anchor to the cell given by index.  The selection
960          anchor is the end of the selection that is fixed while dragging out
961          a selection with the mouse.  The index anchor may be used to refer
962          to the anchor cell.
963
964        $table->selectionClear(first?last?)
965          If any of the cells between first and last (inclusive) are selected,
966          they are deselected.
967           The selection state is not changed for cells outside this range.
968          first may be specified as all to remove the selection from all
969          cells.
970
971        $table->selectionIncludes(index)
972          Returns 1 if the cell indicated by index is currently selected, 0 if
973          it isn't.
974
975        $table->selectionSet(first, ?last?)
976          Selects all of the cells in the range between first and last,
977          inclusive, without affecting the selection state of cells outside
978          that range.
979
980        perltk note this needs to be perlized
981
982        $table->set(?row|col?, index, ?value?, ?index, value, ...?)
983         Sets the specified index to the associated value.  Table validation
984         will not be triggered via this method.  If row or col precedes the
985         list of index/value pairs, then the value is assumed to be a Tcl list
986         whose values will be split and set into the subsequent columns (if
987         row is specified) or rows (for col).  For example,  set row 2,3 {2,3
988         2,4 2,5} will set 3 cells, from 2,3 to 2,5.  The setting of cells is
989         silently bounded by the known table dimensions.
990
991        $table->spans(?index?, ?rows,cols, index, rows,cols, ...?)
992         This command is used to manipulate row/col spans.  When called with
993         no arguments, all known spans are returned as a list of tuples of the
994         form {index span}.  When called with only the index, the span for
995         that index only is returned, if any.  Otherwise an even number of
996         index rows,cols pairs are used to set spans.  A span starts at the
997         index and continues for the specified number of rows and cols.
998         Negative spans are not supported.  A span of 0,0 unsets any span on
999         that cell.  See EXAMPLES for more info.
1000
1001        $table->tag(option, ?arg, arg, ...?)
1002         This command is used to manipulate tags.  The exact behavior of the
1003         command depends on the option argument that follows the tag argument.
1004         cget, cell, and row|col complain about unknown tag names.  The
1005         following forms of the command are currently supported:
1006
1007        $table->tagCell(tagName, ?index, ...?)
1008          With no arguments, prints out the list of cells that use the tag.
1009          Otherwise it sets the specified cells to use the named tag,
1010          replacing any tag that may have been set using this method before.
1011          If tagName is '', the cells are reset to the default tag.  Tags
1012          added during -*tagcommand evaluation do not register here.  If
1013          tagName does not exist, it will be created with the default options.
1014
1015        $table->tagCget(tagName, option)
1016          This command returns the current value of the option named option
1017          associated with the tag given by tagName.  Option may have any of
1018          the values accepted by the tag configure widget command.
1019
1020        $table->tagCol(tagName, ?col, ...?)
1021          With no arguments, prints out the list of cols that use the tag.
1022          Otherwise it sets the specified columns to use the named tag,
1023          replacing any tag that may have been set using this method before.
1024          If <tagName> is '', the cols are reset to the default tag.  Tags
1025          added during -coltagcommand evaluation do not register here.  If
1026          tagName does not exist, it will be created with the default options.
1027
1028        $table->tagConfigure(tagName, ?option?, ?value?, ?option, value, ...?)
1029          This command is similar to the configure widget command except that
1030          it modifies options associated with the tag given by tagName instead
1031          of modifying options for the overall table widget.  If no option is
1032          specified, the command returns a list describing all of the
1033          available options for tagName (see Tk_ConfigureInfo for information
1034          on the format of this list).  If option is specified with no value,
1035          then the command returns a list describing the one named option
1036          (this list will be identical to the corresponding sublist of the
1037          value returned if no option is specified).  If one or more option-
1038          value pairs are specified, then the command modifies the given
1039          option(s) to have the given value(s) in tagName; in this case the
1040          command returns an empty string. See TAGS above for details on the
1041          options available for tags.
1042
1043        $table->tagDelete(tagName)
1044          Deletes a tag.  No error if the tag does not exist.
1045
1046        $table->tagExists(tagName)
1047          Returns 1 if the named tag exists, 0 otherwise.
1048
1049        $table->tagIncludes(tagName, index)
1050          Returns 1 if the specified index has the named tag, 0 otherwise.
1051
1052        $table->tagLower(tagName, ?belowThis?)
1053          Lower the priority of the named tag.  If belowThis is not specified,
1054          then the tag's priority is lowered to the bottom, otherwise it is
1055          lowered to one below belowThis.
1056
1057        $table->tagNames(?pattern?)
1058          If no pattern is specified, shows the names of all defined tags.
1059          Otherwise the pattern is used as a glob pattern to show only tags
1060          matching that pattern.  Tag names are returned in priority order
1061          (highest priority tag first).
1062
1063        $table->tagRaise(tagName, ?aboveThis?)
1064          Raise the priority of the named tag.  If aboveThis is not specified,
1065          then the tag's priority is raised to the top, otherwise it is raised
1066          to one above aboveThis.
1067
1068        $table->tagRow(tagName, ?row, ...?)
1069          With no arguments, prints out the list of rows that use the tag.
1070          Otherwise it sets the specified columns to use the named tag,
1071          replacing any tag that may have been set using this method before.
1072          If tagName is '', the rows are reset to use the default tag.  Tags
1073          added during -rowtagcommand evaluation do not register here.  If
1074          tagName does not exist, it will be created with the default options.
1075
1076        $table->validate(index)
1077         Explicitly validates the specified index based on the current
1078         -validatecommand and returns 0 or 1 based on whether the cell was
1079         validated.
1080
1081        $table->window(option, ?arg, arg, ...?)
1082         This command is used to manipulate embedded windows.  The exact
1083         behavior of the command depends on the option argument that follows
1084         the window argument.  The following forms of the command are
1085         currently supported:
1086
1087        $table->windowCget(index, option)
1088          This command returns the current value of the option named option
1089          associated with the window given by index.  Option may have any of
1090          the values accepted by the window configure widget command.
1091
1092        $table->windowConfigure(index, ?option?, ?value?, ?option, value,
1093        ...?)
1094          This command is similar to the configure widget command except that
1095          it modifies options associated with the embedded window given by
1096          index instead of modifying options for the overall table widget.  If
1097          no option is specified, the command returns a list describing all of
1098          the available options for index  (see Tk_ConfigureInfo for
1099          information on the format of this list).  If option is specified
1100          with no value, then the command returns a list describing the one
1101          named option (this list will be identical to the corresponding
1102          sublist of the value returned if no option is specified).  If one or
1103          more option-value pairs are specified, then the command modifies the
1104          given option(s) to have the given value(s) in index; in this case
1105          the command returns an empty string. See EMBEDDED WINDOWS above for
1106          details on the options available for windows.
1107
1108        $table->windowDelete(index, ?index, ...?)
1109          Deletes an embedded window from the table.  The associated window
1110          will also be deleted.
1111
1112        $table->windowMove(indexFrom, indexTo)
1113          Moves an embedded window from one cell to another.  If a window
1114          already exists in the target cell, it will be deleted.
1115
1116        $table->windowNames(?pattern?)
1117          If no pattern is specified, shows the cells of all embedded windows.
1118          Otherwise the pattern is used as a glob pattern to show only cells
1119          matching that pattern.
1120
1121        $table->xview(args)
1122         This command is used to query and change the horizontal position of
1123         the information in the widget's window.  It can take any of the
1124         following forms:
1125
1126        $table->xview()
1127         Returns a list containing two elements. Each element is a real
1128         fraction between 0 and 1;  together they describe the horizontal span
1129         that is visible in the window. For example, if the first element is
1130         .2 and the second element is .6, 20% of the table's text is off-
1131         screen to the left, the middle 40% is visible in the window, and 40%
1132         of the text is off-screen to the right. These are the same values
1133         passed to scrollbars via the -xscrollcommand option.
1134
1135        $table->xview(index)
1136         Adjusts the view in the window so that the column given by index is
1137         displayed at the left edge of the window.
1138
1139        $table->xviewMoveto(fraction)
1140         Adjusts the view in the window so that fraction of the total width of
1141         the table text is off-screen to the left. fraction must be a fraction
1142         between 0 and 1.
1143
1144        $table->xviewScroll(number, what)
1145         This command shifts the view in the window left or right according to
1146         number and what. Number must be an integer. What must be either units
1147         or pages or an abbreviation of one of these. If what is units, the
1148         view adjusts left or right by number cells on the display;  if it is
1149         pages then the view adjusts by number screenfuls. If number is
1150         negative then cells farther to the left become visible;  if it is
1151         positive then cells farther to the right become visible.
1152
1153        $table->yview(?args?)
1154         This command is used to query and change the vertical position of the
1155         text in the widget's window.  It can take any of the following forms:
1156
1157        $table->yview()
1158          Returns a list containing two elements, both of which are real
1159          fractions between 0 and 1.  The first element gives the position of
1160          the table element at the top of the window, relative to the table as
1161          a whole (0.5 means it is halfway through the table, for example).
1162          The second element gives the position of the table element just
1163          after the last one in the window, relative to the table as a whole.
1164          These are the same values passed to scrollbars via the
1165          -yscrollcommand option.
1166
1167        $table->yview(index)
1168          Adjusts the view in the window so that the row given by index is
1169          displayed at the top of the window.
1170
1171        $table->yviewMoveto(fraction)
1172          Adjusts the view in the window so that the element given by fraction
1173          appears at the top of the window. Fraction is a fraction between 0
1174          and 1;  0 indicates the first element in the table, 0.33 indicates
1175          the element one-third the way through the table, and so on.
1176
1177        $table->yviewscroll(number, what)
1178          This command adjusts the view in the window up or down according to
1179          number and what.  Number must be an integer.  What must be either
1180          units or pages.  If what is units, the view adjusts up or down by
1181          number cells; if it is pages then the view adjusts by number
1182          screenfuls.  If number is negative then earlier elements become
1183          visible; if it is positive then later elements become visible.
1184

Default Bindings

1186       The initialization creates class bindings that give the following
1187       default behaviour:
1188
1189       [1]
1190        Clicking Button-1 in a cell activates that cell.  Clicking into an
1191        already active cell moves the insertion cursor to the character
1192        nearest the mouse.
1193
1194       [2]
1195        Moving the mouse while Button-1 is pressed will stroke out a selection
1196        area. Exiting while Button-1 is pressed causing scanning to occur on
1197        the table along with selection.
1198
1199       [3]
1200        Moving the mouse while Button-2 is pressed causes scanning to occur
1201        without any selection.
1202
1203       [4]
1204        Home moves the table to have the origin in view.
1205
1206       [5]
1207        End moves the table to have the end cell in view.
1208
1209       [6]
1210        Control-Home moves the table to the origin and activates that cell.
1211
1212       [7]
1213        Control-End moves the table to the end and activates that cell.
1214
1215       [8]
1216        Shift-Control-Home extends the selection to the origin.
1217
1218       [9]
1219        Shift-Control-End extends the selection to the end.
1220
1221       [10]
1222        The left, right, up and down arrows move the active cell.
1223
1224       [11]
1225        Shift-<arrow> extends the selection in that direction.
1226
1227       [12]
1228        Control-leftarrow and Control-rightarrow move the insertion cursor
1229        within the cell.
1230
1231       [13]
1232        Control-slash selects all the cells.
1233
1234       [14]
1235        Control-backslash clears selection from all the cells.
1236
1237       [15]
1238        Backspace deletes the character before the insertion cursor in the
1239        active cell.
1240
1241       [16]
1242        Delete deletes the character after the insertion cursor in the active
1243        cell.
1244
1245       [17]
1246        Escape rereads the value of the active cell from the specified data
1247        source, discarding any edits that have may been performed on the cell.
1248
1249       [18]
1250        Control-a moves the insertion cursor to the beginning of the active
1251        cell.
1252
1253       [19]
1254        Control-e moves the insertion cursor to the end of the active cell.
1255
1256       [20]
1257        Control-minus and Control-equals decrease and increase the width of
1258        the column with the active cell in it.
1259
1260       [21]
1261        Moving the mouse while Button-3 (the right button on Windows) is
1262        pressed while you are over a border will cause interactive resizing of
1263        that row and/or column to occur, based on the value of -resizeborders.
1264        Some bindings may have slightly different behavior dependent on the
1265        -selectionmode of the widget. If the widget is disabled using the
1266        -state option, then its view can still be adjusted and cells can still
1267        be selected, but no insertion cursor will be displayed and no cell
1268        modifications will take place. The behavior of tables can be changed
1269        by defining new bindings for individual widgets or by redefining the
1270        class bindings.  The default bindings are either compiled in the
1271        TableMatrix.pm file
1272

Performance Issues

1274       The number of rows and columns or a table widget should not
1275       significantly affect the speed of redraw.  Recalculation and redraw of
1276       table parameters and cells is restricted as much as possible. The
1277       display cell with the insert cursor is redrawn each time the cursor
1278       blinks, which causes a steady stream of graphics traffic.  Set the
1279       -insertofftime option to 0 avoid this.  The use of a -command with the
1280       table without a cache can cause significant slow-down, as the command
1281       is called once for each request of a cell value.
1282

Examples

1284       Set the topleft title area to be one spanning cell.  This overestimates
1285       both row and column span by one, but the command does all the
1286       constraining for us.  $table span [$table cget -roworigin],[$table cget
1287       -colorigin] [$table cget -titlerows],[$table cget -titlecols] Force a
1288       table window refresh (useful for the slight chance that a bug in the
1289       table is not causing proper refresh):  $table configure -padx [$table
1290       cget -padx]
1291

Keywords

1293       table, widget, extension
1294
1295
1296
1297perl v5.38.0                      2023-07-21                    TableMatrix(3)
Impressum