The grid command is used to communicate with the grid geometry manager that arranges widgets in rows and
columns inside of another window, called the geometry container (or container window). The grid command
can have any of several forms, depending on the option argument:
gridwindow ?window...? ?options?
If the first argument to grid is suitable as the first window argument to gridconfigure, either a
window name (any value starting with .) or one of the characters x or ^ (see the RELATIVEPLACEMENT section below), then the command is processed in the same way as gridconfigure.
gridanchorwindow ?anchor?
The anchor value controls how to place the grid within the container window when no row/column has
any weight. See THEGRIDALGORITHM below for further details. The default anchor is nw.
gridbboxwindow ?columnrow? ?column2row2?
With no arguments, the bounding box (in pixels) of the grid is returned. The return value
consists of 4 integers. The first two are the pixel offset from the container window (x then y)
of the top-left corner of the grid, and the second two integers are the width and height of the
grid, also in pixels. If a single column and row is specified on the command line, then the
bounding box for that cell is returned, where the top left cell is numbered from zero. If both
column and row arguments are specified, then the bounding box spanning the rows and columns
indicated is returned.
gridcolumnconfigurewindowindex ?-optionvalue...?
Query or set the column properties of the index column of the geometry container, window. The
valid options are -minsize, -weight, -uniform and -pad. If one or more options are provided, then
index may be given as a list of column indices to which the configuration options will operate on.
Indices may be integers, window names or the keyword all. For all the options apply to all columns
currently occupied be content windows. For a window name, that window must be a content of this
container and the options apply to all columns currently occupied be the content. The -minsize
option sets the minimum size, in screen units, that will be permitted for this column. The
-weight option (an integer value) sets the relative weight for apportioning any extra spaces among
columns. A weight of zero (0) indicates the column will not deviate from its requested size. A
column whose weight is two will grow at twice the rate as a column of weight one when extra space
is allocated to the layout. The -uniform option, when a non-empty value is supplied, places the
column in a uniformgroup with other columns that have the same value for -uniform. The space for
columns belonging to a uniform group is allocated so that their sizes are always in strict
proportion to their -weight values. See THEGRIDALGORITHM below for further details. The -pad
option specifies the number of screen units that will be added to the largest window contained
completely in that column when the grid geometry manager requests a size from the containing
window. If only an option is specified, with no value, the current value of that option is
returned. If only the container window and index is specified, all the current settings are
returned in a list of “-optionvalue” pairs.
gridconfigurewindow ?window...? ?options?
The arguments consist of the names of one or more content windows followed by pairs of arguments
that specify how to manage the content. The characters -, x and ^, can be specified instead of a
window name to alter the default location of a window, as described in the RELATIVEPLACEMENT
section, below. The following options are supported:
-columnn
Insert the window so that it occupies the nth column in the grid. Column numbers start
with 0. If this option is not supplied, then the window is arranged just to the right of
previous window specified on this call to grid, or column “0” if it is the first window.
For each x that immediately precedes the window, the column position is incremented by one.
Thus the x represents a blank column for this row in the grid.
-columnspann
Insert the window so that it occupies n columns in the grid. The default is one column,
unless the window name is followed by a -, in which case the columnspan is incremented once
for each immediately following -.
-incontainer
Insert the window(s) in the container window given by container. The default is the first
window's parent window.
-ipadxamount
The amount specifies how much horizontal internal padding to leave on each side of the
content. This is space is added inside the content border. The amount must be a valid
screen distance, such as 2 or .5c. It defaults to 0.
-ipadyamount
The amount specifies how much vertical internal padding to leave on the top and bottom of
the content. This space is added inside the content border. The amount defaults to 0.
-padxamount
The amount specifies how much horizontal external padding to leave on each side of the
content, in screen units. Amount may be a list of two values to specify padding for left
and right separately. The amount defaults to 0. This space is added outside the content
border.
-padyamount
The amount specifies how much vertical external padding to leave on the top and bottom of
the content, in screen units. Amount may be a list of two values to specify padding for
top and bottom separately. The amount defaults to 0. This space is added outside the
content border.
-rown Insert the content so that it occupies the nth row in the grid. Row numbers start with 0.
If this option is not supplied, then the content is arranged on the same row as the
previous content specified on this call to grid, or the next row after the highest occupied
row if this is the first content.
-rowspann
Insert the content so that it occupies n rows in the grid. The default is one row. If the
next grid command contains ^ characters instead of content that line up with the columns of
this content, then the rowspan of this content is extended by one.
-stickystyle
If a content's cell is larger than its requested dimensions, this option may be used to
position (or stretch) the content within its cell. Style is a string that contains zero
or more of the characters n, s, e or w. The string can optionally contain spaces or
commas, but they are ignored. Each letter refers to a side (north, south, east, or west)
that the content will “stick” to. If both n and s (or e and w) are specified, the content
will be stretched to fill the entire height (or width) of its cavity. The -sticky option
subsumes the combination of -anchor and -fill that is used by pack. The default is “”,
which causes the content to be centered in its cavity, at its requested size.
If any of the content is already managed by the geometry manager then any unspecified options for
them retain their previous values rather than receiving default values.
gridcontentwindow ?-optionvalue?
If no options are supplied, a list of all of the content in window is returned, most recently
managed first. Option can be either -row or -column which causes only the content in the row (or
column) specified by value to be returned.
gridforgetwindow ?window...?
Removes each of the windows from grid for its container and unmaps their windows. The content
will no longer be managed by the grid geometry manager. The configuration options for that window
are forgotten, so that if the window is managed once more by the grid geometry manager, the
initial default settings are used.
If the last content window of the container becomes unmanaged, this will also send the virtual 2
event <<NoManagedChild>> to the container; the container may choose to resize itself (or otherwise 2
respond) to such a change.
gridinfowindow
Returns a list whose elements are the current configuration state of the content given by window
in the same option-value form that might be specified to gridconfigure. The first two elements
of the list are “-incontainer” where container is the windows's container window.
gridlocationwindowxy
Given x and y values in screen units relative to the container window, the column and row number
at that x and y location is returned. For locations that are above or to the left of the grid, -1
is returned.
gridpropagatewindow ?boolean?
If boolean has a true boolean value such as 1 or on then propagation is enabled for window, which
must be a window name (see GEOMETRYPROPAGATION below). If boolean has a false boolean value then
propagation is disabled for window. In either of these cases an empty string is returned. If
boolean is omitted then the command returns 0 or 1 to indicate whether propagation is currently
enabled for window.
Propagation is enabled by default.
gridrowconfigurewindowindex ?-optionvalue...?
Query or set the row properties of the index row of the geometry container, window. The valid
options are -minsize, -weight, -uniform and -pad. If one or more options are provided, then index
may be given as a list of row indices to which the configuration options will operate on. Indices
may be integers, window names or the keyword all. For all the options apply to all rows currently
occupied by content windows. For a window name, that window must be a content window of this
container and the options apply to all rows currently occupied by the container window. The
-minsize option sets the minimum size, in screen units, that will be permitted for this row. The
-weight option (an integer value) sets the relative weight for apportioning any extra spaces among
rows. A weight of zero (0) indicates the row will not deviate from its requested size. A row
whose weight is two will grow at twice the rate as a row of weight one when extra space is
allocated to the layout. The -uniform option, when a non-empty value is supplied, places the row
in a uniformgroup with other rows that have the same value for -uniform. The space for rows
belonging to a uniform group is allocated so that their sizes are always in strict proportion to
their -weight values. See THEGRIDALGORITHM below for further details. The -pad option
specifies the number of screen units that will be added to the largest window contained completely
in that row when the grid geometry manager requests a size from the containing window. If only an
option is specified, with no value, the current value of that option is returned. If only the
container window and index is specified, all the current settings are returned in a list of
“-option value” pairs.
gridremovewindow ?window...?
Removes each of the windows from grid for its container and unmaps their windows. The content
will no longer be managed by the grid geometry manager. However, the configuration options for
that window are remembered, so that if the content window is managed once more by the grid
geometry manager, the previous values are retained.
If the last content window of the container becomes unmanaged, this will also send the virtual 2
event <<NoManagedChild>> to the container; the container may choose to resize itself (or otherwise 2
respond) to such a change.
gridsizecontainer
Returns the size of the grid (in columns then rows) for container. The size is determined either
by the content occupying the largest row or column, or the largest column or row with a -minsize,
-weight, or -pad that is non-zero.
gridslaveswindow ?-optionvalue?
Synonym for gridcontentwindow ?-optionvalue?.