GridFrame
Bases: Frame
A Frame with simplified grid-based layout management and auto-placement.
GridFrame extends the bootstack Frame with automatic grid-based layout management, including support for row/column definitions, gap spacing, auto-placement, and default sticky behavior.
Children gridded into this frame automatically receive the frame's
default layout options. Simply use the standard grid() method
on child widgets — no special add() method is needed.
Example
frame = GridFrame(columns=3, gap=10, sticky_items="nsew")
Label(frame, text="A").grid() # auto-placed at row=0, col=0
Label(frame, text="B").grid() # auto-placed at row=0, col=1
Label(frame, text="C").grid() # auto-placed at row=0, col=2
Label(frame, text="D").grid() # auto-placed at row=1, col=0
Label(frame, text="Wide").grid(columnspan=2) # spans 2 columns
__init__
__init__(
master: Master = None,
*,
rows: Optional[
Union[int, list[Union[int, str]]]
] = None,
columns: Optional[
Union[int, list[Union[int, str]]]
] = None,
gap: Gap = 0,
sticky_items: Optional[Sticky] = None,
propagate: Optional[bool] = None,
auto_flow: AutoFlow = "row",
**kwargs: Any,
) -> None
Create a GridFrame with automatic grid-based layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
master
|
Master
|
Parent widget. If None, uses the default root window. |
None
|
rows
|
Optional[Union[int, list[Union[int, str]]]]
|
Number of rows as an |
None
|
columns
|
Optional[Union[int, list[Union[int, str]]]]
|
Number of columns or a list of size specs (same format as |
None
|
gap
|
Gap
|
Spacing between cells. An |
0
|
sticky_items
|
Optional[Sticky]
|
Default |
None
|
propagate
|
Optional[bool]
|
If False, the frame will not resize to fit its contents. Defaults to None (Tk default behaviour). |
None
|
auto_flow
|
AutoFlow
|
Auto-placement mode — |
'row'
|
**kwargs
|
Any
|
Additional keyword arguments forwarded to |
{}
|
configure_row
configure_row(
index: int,
weight: int = 1,
minsize: Optional[int] = None,
pad: Optional[int] = None,
) -> None
Configure a row's properties.
configure_column
configure_column(
index: int,
weight: int = 1,
minsize: Optional[int] = None,
pad: Optional[int] = None,
) -> None
Configure a column's properties.