_________________________________________________________________
table arrange master
table cget master ?item? option
table configure master ?item?... ?option value?...
table extents master item
table forget slave ?slave?...
table info master item
table locate master x y
table masters ?switch? ?arg?
table search master ?switch arg?...
_________________________________________________________________
The table geometry manager arranges widgets in a table. It's easy to align widgets (horizontally and vertically) or to create empty space to balance the arrangement of the widgets. Widgets, called slaves, are arranged inside of another widget called the master. Slaves are positioned at row,column locations and may span any number of rows or columns. More than one widget can occupy a single location.
The placement of slave windows determines both the size and arrangement of the table. The table queries the requested size of each slave. The requested size of a widget is the natural size of the widget (before the widget is shrunk or expanded). The height of each row and the width of each column is the largest slave spanning that row or column. The size of the table is in turn the sum of the row and column sizes. This is the table's normal size.
The total number of rows and columns in a table is determined from the indices specified. The table grows dynamically as windows are added at larger indices.
# Create a table in the root window table .
The window . is now the master window of the table. Widgets (slave windows) packed into the table will be displayed within the confines of the master window.
You add widgets to the table by row and column location. Row and column indices start from zero.
label .title -text "This is a title"
# Add a label to the table
table . .title 0,0
The label .title is added to the table. We can add more widgets in the same way.
button .ok -text "Ok"
button .cancel -text "Cancel"
# Add two buttons
table . .ok 1,0
table . .cancel 1,1
Two buttons .ok and .cancel are now packed into the second row of the table. They each occupy one cell of the table. By default, widgets span only a single row and column.
The first column contains two widgets, .title and .ok. By default, the widest of the two widgets will define the width of the column. However, we want .title to be centered horizontally along the top of the table. We can make .title span two columns using the configure operation.
# Make the label span both columns table configure . .title -cspan 2
The label .title will now be centered along the top row of the table.
In the above example, we've create and arranged the layout for the table invoking the table command several times. Alternately, we could have used a single table command.
label .title -text "This is a title" button .ok -text "Ok"
button .cancel -text "Cancel"
# Create and pack the table
table . \
.title 0,0 -cspan 2 \
table configure . -propagate no
You can also set the width of height of the table to a specific value. This supersedes the calculated table size.
# Make the master window 4 inches wide, 3 inches high table configure . -reqwidth 4i -reqheight 3i
If a widget is smaller than the cell(s) it occupies, the widget will float within the extra space. By default, the widget will be centered within the space, but you can anchor the widget to any side of cell using the -anchor configuration option.
table configure . .ok -anchor w
The -fill option expands the slave widget to fill the extra space either vertically or horizontally (or both).
# Make the title label fill the entire top row table configure . .title -cspan 2 -fill x
# Each button will be as height of the 2nd row. table configure . .ok .cancel -fill y
The width of .title will be the combined widths of both columns. Both .ok and .cancel will become as tall as the second row.
The -padx and -pady options control the amount of padding around the slave window. Both options take a list of one or two values.
# Pad the title by two pixels above and below. table configure . .title -pady 2
# Pad each button 2 pixels on the left, and 4 on the right. table configure . .ok .cancel -padx { 2 4 }
If the list has only one value, then both exterior sides (top and bottom or left and right) of the slave window are padded by that amount. If the list has two elements, the first specifies padding for the top or left side and the second for the bottom or right side.
Like the master window, you can also override the requested widths and heights of slave windows using the -reqwidth and -reqheight options. This is especially useful with character-based widgets (such as buttons, labels, text, listbox, etc) that let you specify their size only in units of characters and lines, instead of pixels.
# Make all buttons one inch wide table configure . .ok .cancel -reqwidth 1i
Each row and column of the table can be configured, again using the configure operation. Rows are and columns are designated by Ri and Ci respectively, where i is the index of the row or column.
For example, you can set the size of a row or column.
# Make the 1st column 2 inches wide table configure . c0 -width 2.0i
# Make the 2nd row 1/2 inch high. table configure . r1 -height 0.5i
The new size for the row or column overrides its calculated size. If no slave windows span the row or column, its height or width is zero. So you can use the -width and -height options to create empty spaces in the table.
# Create an empty row and column table configure . r2 c2 -width 1i
The -pady option lets you add padding to the top and bottom sides of rows. The -padx option adds padding to the left and right sides of columns. Both options take a list of one or two values.
# Pad above the title by two pixels table configure . r0 -pady { 2 0 } # Pad each column 4 pixels on the left, and 2 on the right. table configure . c* -padx { 2 4 }
Notice that you can configure all the rows and columns using either R* or C*.
When the master window is resized, the rows and columns of the table are also resized. The -resize option indicates whether the row or column can be shrunk or stretched. If the value is shrink, the row or column can only be resized smaller. If expand, it can only be resized larger. If none, the row or column is frozen at its normal size.
# Let the 1st column get smaller, but not bigger table configure . c0 -resize shrink
# Let the 2nd column get bigger, not smaller table configure . c1 -resize expand
# Don't resize the first row
table configure . r0 -resize none
The following example packs a canvas, two scrollbars, and a title. The rows and columns containing the scrollbars are frozen at their normal size, so that even if the frame is resized, the scrollbars will remain the same width.
table . \
# Create an empty space to balance the scrollbar table configure . c0 -width .vscroll
Note that the value of the -width option is the name of a slave window. This indicates that the width of the column should be the same as the requested width of .vscroll.
Finally, the forget operation removes slave windows from the table.
# Remove the windows from the table table forget .quit .frame
It's not necessary to specify the master window. The table command determines the master window from the slave window name.
table master ?slave index option value?... Adds the widget slave to the table at index. Index is a row,column position in the table. It must be in the form row,column where row and column are the respective row and column numbers, starting from zero (0,0 is the upper leftmost position). Row and column may also be numeric expressions which are recursively evaluated. If a table doesn't exist for master, one is created. Slave is the path name of the window, which must already exist, to be arranged inside of master. Option and value are described in the SLAVE OPTIONS section.
table arrange master
Forces the table to compute its layout immediately. Normally, the table geometry manager will wait until the next idle point, before calculating the size of its rows and columns. This is useful for collecting the normal sizes of rows and columns, which are based upon the requested slave window sizes.
table cget master ?item? option
Returns the current value of the configuration option specific to item given by option. Item is either a row or column index, or the path name of a slave window. Item can be in any form describe in the configure operation below. If no item argument is provided, then the configuration option is for the table itself. Option may be any one of the options described in the appropiate section for item.
table configure master item... ?option value?... Queries or modifies the configuration options specific to item. If no option is specified, this command returns a list describing all of the available options for item If the argument item is omitted, then the specified configuration options are for the table itself. Otherwise item must be either a row or column specification, or the path name of a slave window. The following item types are available.
No argument
Specifies that the table itself is to be queried. See the TABLE OPTIONS section for a description of the option-value pairs for the table.
The option and value pairs are specific to item. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns the empty string.
table extents master index
Queries the location and dimensions of row and columns in the table. Index can be either a row or column index or a table index. Returns a list of the x,y coordinates (upperleft corner) and dimensions (width and height) of the cell, row, or column.
table forget slave ?slave?...
Requests that slave no longer have its geometry managed. Slave is the pathname of the window currently managed by some table. The window will be unmapped so that it no longer appears on the screen. If slave is not currently managed by any table, an error message is returned, otherwise the empty string.
table info master item
Returns a list of the current configuration options for item. The list returned is exactly in the form that might be specified to the table command. It can be used to save and reset table configurations. Item must be one of the following.
No argument
Specifies that the table itself is to be queried.
table locate master x y
Returns the table index (row,column) of the cell containing the given screen coordinates. The x and y arguments represent the x and y coordinates of the sample point to be tested.
table masters ?switch arg?
Returns a list of all master windows matching a given criteria (using switch and arg). If no switch and arg arguments are given, the names of all master windows (only those using the table command) are returned. The following are valid switches:
table configure master ?option value?...
The following options are available for the table:
table configure master slave ?option value?...
Slave must be the path name of a window already packed in the table associated with master. The following options are available for slave windows:
table configure master Ci ?option value?...
If the index is specified as C*, then all columns of the table will be configured. The following options are available for table columns.
table configure master Ri ?option value?...
If the index is specified as R*, then all rows of the table will be configured. The following options are available for table rows.
table . \
The scrollbars will get no smaller than 1/8 of an inch, or bigger than 1/2 inch. The initial size will be their requested size, so long as it is within the specified bounds.
How the elements of the list are interpreted is dependent upon the number of elements in the list.
{ min max nom }
Specifies minimum and maximum size limits, but also specifies a nominal size nom. This overrides the calculated size of the window or partition.
frame .frame -bd 1 -relief sunken button .quit -text "Quit"
# Put both the frame and the button in the same cell. table . \
.quit 1,0 -padx 2 -pady 2 \ .frame 1,0 -fill both
There is no way to detect if a window is already a master of a different geometry manager. Bizarre window repositioning may occur, as each geometry manager applies its own brand of layout policies. If the window is a top level window, the window manager may become involved, responding to the each new size request and your session may hang.