Grid#
The grid geometry manager places a widget in a row/column grid in its parent. This page is the method spec; Arranging widgets teaches when to reach for grid.
In ttkbootstrap grid (and grid_configure) return the widget, so
construction and placement can be chained.
The canonical upstream reference is the Tk grid manual page (Tcl 8.6).
Options#
Every option below is a keyword argument to grid().
Option |
Type |
Description |
|---|---|---|
rowcolumn |
|
The cell to occupy (0-based). |
rowspancolumnspan |
|
How many rows / columns the widget covers. Default |
|
|
Which sides of the cell the widget sticks to — any combination of
|
padxpady |
|
External space around the widget, in pixels. A |
ipadxipady |
|
Internal padding added to the widget’s own size, in pixels. |
|
|
Grid inside a container other than the parent (the container must be the parent or one of its descendants). Rarely needed. |
Placing a widget#
- grid(**options)
Place the widget in a cell (or span of cells), using the options above. Alias:
grid_configure.- Returns:
the widget (ttkbootstrap), for chaining.
- grid_forget()
Unmap the widget and forget its grid options.
- Returns:
None.
- grid_remove()
Unmap the widget but remember its options, so a later
grid()with no arguments restores it in place.- Returns:
None.
- grid_info()
Return the widget’s current grid options.
- Return type:
Configuring the container#
These are called on the parent to shape its rows and columns — most
importantly weight, which decides how leftover space is shared when the
window resizes.
- columnconfigure(index, **options)
Configure a column of this container’s grid. Alias:
grid_columnconfigure.- Parameters:
index – the column number (or a list of them).
options –
weight(share of extra space),minsize,pad,uniform(columns sharing a group grow together).
- Returns:
the current settings when queried, else
None.
- rowconfigure(index, **options)
Configure a row of this container’s grid. Alias:
grid_rowconfigure. Takes the same options ascolumnconfigure().- Parameters:
index – the row number (or a list of them).
- Returns:
the current settings when queried, else
None.
- grid_propagate(flag=None)
Get or set whether this container resizes to fit its gridded children. Set
Falseto keep a fixed size.- Parameters:
flag (bool) – the new setting; omit to query.
- Returns:
the current setting when queried, else
None.
- grid_slaves(row=None, column=None)
Return the widgets this container manages with grid, optionally filtered to a row and/or column.
- Return type:
- grid_location(x, y)
Return the
(column, row)cell that covers a pixel coordinate.
- grid_bbox(column=None, row=None, col2=None, row2=None)
Return the bounding box
(x, y, width, height)of a cell or a span of cells, in pixels.
- grid_anchor(anchor=None)
Get or set where the whole grid is anchored inside the container when it is larger than the grid.
- Parameters:
anchor – an anchor like
"center"or"nw"; omit to query.