Unless you take certain measures, the width of a grid
column inside a given widget will be equal to the width
of its widest cell, and the height of a grid row will
be the height of its tallest cell. The
sticky
attribute on a widget
controls only where it will be placed if it doesn't
completely fill the cell.
If you want to override this automatic sizing of columns and rows, use these methods on the parent widget that contains the grid layout:
W
.columnconfigure ( N
, option
=value
, ... )
In the grid layout inside widget
,
configure column W
so that the given
N
has the given option
value
. For options, see the table
below.
W
.rowconfigure ( N
, option
=value
, ... )
In the grid layout inside widget
,
configure row W
so that the given
N
has the given option
value
. For options, see the table
below.
Here are the options used for configuring column and row sizes.
minsize
| The column or row's minimum size in pixels. If there is nothing in the given column or row, it will not appear, even if you use this option. |
pad
| A number of pixels that will be added to the given column or row, over and above the largest cell in the column or row. |
weight
|
To make a column or row stretchable, use this
option and supply a value that gives the relative
weight of this column or row when distributing
the extra space. For example, if a widget
w contains a grid
layout, these lines will distribute three-fourths
of the extra space to the first column and
one-fourth to the second column:
w.columnconfigure(0, weight=3) w.columnconfigure(1, weight=1)If this option is not used, the column or row will not stretch. |