Skip to content

PackFrame

Bases: Frame

A Frame with simplified pack-based layout management.

PackFrame extends the bootstack Frame with automatic pack-based layout management, including support for direction, gap spacing, and default fill/expand behavior.

Children packed into this frame automatically receive the frame's default layout options. Simply use the standard pack() method on child widgets — no special add() method is needed.

Example
frame = PackFrame(direction="vertical", gap=10, fill_items="x")
Label(frame, text="First").pack()
Label(frame, text="Second").pack()
Button(frame, text="Click").pack(expand=True)  # override default

__init__

__init__(
    master: Master = None,
    *,
    direction: Direction = "vertical",
    gap: int = 0,
    fill_items: Optional[Fill] = None,
    expand_items: Optional[bool] = None,
    anchor_items: Optional[Anchor] = None,
    propagate: Optional[bool] = None,
    **kwargs: Any,
) -> None

Create a PackFrame with automatic pack-based layout.

Parameters:

Name Type Description Default
master Master

Parent widget. If None, uses the default root window.

None
direction Direction

Layout direction — 'vertical', 'horizontal', 'row', 'column', 'row-reverse', or 'column-reverse'. Defaults to 'vertical'.

'vertical'
gap int

Spacing between children in pixels. Defaults to 0.

0
fill_items Optional[Fill]

Default fill option for children ('none', 'x', 'y', or 'both'). If None, no default fill is applied.

None
expand_items Optional[bool]

Default expand option for children. If None, no default expand is applied.

None
anchor_items Optional[Anchor]

Default anchor for children. If None, no default anchor is applied.

None
propagate Optional[bool]

If False, the frame will not resize to fit its contents. Defaults to None (Tk default behaviour).

None
**kwargs Any

Additional keyword arguments forwarded to Frame.

{}