beetlebug▾
/

grid columnconfigure

Gives or sets the options of one or more columns of a grid.

grid columnconfigure CONTAINER INDEX
grid columnconfigure CONTAINER INDEX OPTION
grid columnconfigure CONTAINER INDEX OPTION VALUE ?OPTION VALUE ...?

Description

INDEX is a column number, a list of column numbers, all for each column that has a widget, or the name of a widget in the grid for each of its columns. With no option, gives each option and its value for one column. With one option, gives its value. With pairs of options and values, sets them on each column of INDEX.

Options

OptionTypeDefaultDescription
-minsizescreen distance0The smallest width of the column.
-padscreen distance0Extra width of the column, half at each side of its widgets.
-uniformstringemptyA group name: the columns of one group have the same width.
-weightinteger0The share of the extra width of the container that the column gets.

-minsize DISTANCE

The smallest width of the column.

The column is at least DISTANCE wide, also with no widget in it.

% frame .mn
> frame .mn.a -width 10 -height 10
> grid .mn.a
> grid columnconfigure .mn 0 -minsize 50
> pack .mn
> update
> winfo reqwidth .mn
50
% grid columnconfigure .mn 0 -minsize x
bad screen distance "x"
-errorcode NONE

-pad DISTANCE

Extra width of the column, half at each side of its widgets.

The column is DISTANCE wider than its widest widget. The value must not be negative.

% frame .pd
> frame .pd.a -width 10 -height 10
> grid .pd.a
> grid columnconfigure .pd 0 -pad 6
> pack .pd
> update
> list [winfo reqwidth .pd] [winfo x .pd.a]
16 3
% grid columnconfigure .pd 0 -pad -1
invalid arg "-pad": should be non-negative
-errorcode NONE

-uniform GROUP

A group name: the columns of one group have the same width.

Each column with the same GROUP gets the width of the widest column of the group, in proportion to its -weight. An empty value puts the column in no group.

% frame .un
> frame .un.a -width 10 -height 10
> frame .un.b -width 30 -height 10
> grid .un.a .un.b
> grid columnconfigure .un {0 1} -uniform g
> pack .un
> update
> winfo reqwidth .un
60

Each string is a valid group name.

-weight N

The share of the extra width of the container that the column gets.

When the container is wider than the grid, the extra width goes to the columns in proportion to their weights. A column with the weight 0 keeps its width. The value must not be negative.

# The column is 100 pixels wide, and the widget is at its center.
% frame .wt -width 100 -height 40
> grid propagate .wt 0
> pack .wt
> frame .wt.a -width 10 -height 10
> grid .wt.a
> grid columnconfigure .wt 0 -weight 1
> update
> winfo x .wt.a
45
% grid columnconfigure .wt 0 -weight -1
invalid arg "-weight": should be non-negative
-errorcode NONE

Returns

A list of options and values, one value, or an empty string.

Examples

% frame .cc
> grid columnconfigure .cc 0
-minsize 0 -pad 0 -uniform {} -weight 0

% frame .cc2
> frame .cc2.a
> grid .cc2.a
> grid columnconfigure .cc2 {0 1} -weight 2
> grid columnconfigure .cc2 .cc2.a -pad 3
> list [grid columnconfigure .cc2 1 -weight] [grid columnconfigure .cc2 0 -pad]
2 3

Errors

% grid columnconfigure .cc x -weight 1
illegal index "x"
-errorcode NONE

% grid columnconfigure .cc -1 -weight 1
"-1" is out of range
-errorcode NONE

% grid columnconfigure .cc {0 1}
must specify a single element on retrieval
-errorcode NONE

% grid columnconfigure .cc 0 -bogus 1
bad option "-bogus": must be -minsize, -pad, -uniform, or -weight
-errorcode NONE

% grid columnconfigure .cc
wrong # args: should be "grid columnconfigure master index ?-option value ...?"
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also