TkTable
subclass of Widget
creates a Table of entries or text fields. This acts much like a
spreadsheet. This Table is based on the tktable widget (and needs it to be available
as a package). Classy::TkTable mimics some of the behaviour/API of the older Classy::Table
widget. However: the coordinates are in row major order (as in Tktable) and not in
column major (as in Classy::Table).
The Classy::TkTable widget has much better performance (because of the underlying
tktable widget), and has some new options not in Classy::Table (all options of tktable,
and some extra)
The bindings are more like that of most spreadsheets. It hase 2 "modes": a selection where
you basically move the cell, and editing will replace the current value in the current cell,
and a editing mode where you edit within the cell (started by double-clicking or F2).
Data for Classy::TkTable can be supplied in several ways.
- a variable
- the variable is set by using the -variable option.
The type of value is set using the -variabletype option, that can have one of the following types:
- array
- the same as the default Tktable variable
- list
- a list of lists: The first element is the first row in the table, etc.
- tlist
- a list of lists transposed: The first element is the first column in the table, etc.
- table
- an Extral table
- Command
- The Table can have an associated command. This is used to get the data
to display in the Table and te change data when it
is edited. The table command will be called with the following
parameters:
- command object x y ?value?
- the parameter object is the name of the Table.
When no value is given, the command must return the value to be
shown in the given cell.
When the command fails, the error message will be shown in the affected cell.
- When value is given, it is the new value of the cell.
If the setcommand fails, the previous value will be restored.
You can have the command behave like the TkTable -command option by specifying -variabletype tktable
TkTable specific options
- Command-Line Name: -autosize
- Database Name: autoSize
- Database Class: AutoSize
-
"pathName autosize" will adapt column and row sizes automatically to the data in the table.
This command is automatically run when defining e.g. a new variable or type.
"pathName autosizecol" and "pathName autosizerow" can be used to automatically
adapt the size of a givven column or row
The -autosize option consists of a list of numbers giving the minimum
and maximum width and heights of the columns and rows respectively.
colminsize colmaxsize rowminsize rowmaxsize
if some numbers are not given (the list contains less than 4 items),
defaults (1 60 1 4) are used. -1 can be used for unbounded
- Command-Line Name: -command
- Database Name: Command
- Database Class: Command
-
gives the command that will be called to get or set the value of a given cell. It must have the
following format:
command object x y ?value?
The parameters given to the command are the Table objects name, the x and
y coordinate in the table.
If the parameter value is not given, the command should return thew current value of the cell
given by coordinates x and y in the table.
If value is given, the command should change the value of the cell to this new value.
If the setcommand fails, the previous value will be restored.
- Command-Line Name: -cols
- Database Name: cols
- Database Class: Cols
-
gives the number of columns in the Table
- Command-Line Name: -rows
- Database Name: rows
- Database Class: rows
-
gives the number of rows in the Table
- Command-Line Name: -colsize
- Database Name: colsize
- Database Class: colsize
-
gives the default column size
- Command-Line Name: -rowsize
- Database Name: rowsize
- Database Class: rowsize
-
gives the default row size
- Command-Line Name: -xresize
- Database Name: xResize
- Database Class: Resize
-
allow columns to be resized
- Command-Line Name: -yresize
- Database Name: yResize
- Database Class: Resize
-
allow rows to be resized
- Command-Line Name: -labels
- Database Name: labels
- Database Class: Labels
-
Add a title line with the given labels
TkTable specific methods
-
pathname copy
-
puts the data in the selected cells in the selection
-
pathname cut
-
puts the data in the selected cells in the selection, and deletes it afterwards
-
pathname paste ?data?
-
paste data in the Table. The data will replace the contents of each selected cell.