Skip to content

Pack

This capability documents one focused aspect of the widget interface (Tk/Tcl-style behavior + bootstack extensions).

Note: You typically won’t use bootstack.core.capabilities.pack directly. This page describes the behavior that widgets expose.

Pack geometry manager helpers (pack).

Tk's pack geometry manager places widgets relative to the sides of a container.

In bootstack v2 you may prefer higher-level layout containers (e.g. PackFrame) for most UI layout. This mixin documents the underlying Tkinter pack_* API as an escape hatch and for interoperability with existing Tk code.

Notes
  • pack() attaches a widget to a parent container that is using pack.
  • pack_propagate(False) prevents a container from resizing to fit its children.
  • fill, expand, and side control how a widget consumes available space.
  • If the parent has a _on_child_pack hook (e.g. PackFrame), layout defaults are applied automatically.

pack

pack(cnf: dict[str, Any] | None = None, **kw: Any) -> Self

Position this widget using the pack geometry manager.

Parameters:

Name Type Description Default
cnf dict[str, Any] | None

Optional dict of pack options.

None
**kw Any

Pack options. Common options include: - side: Which side to pack against ("top", "bottom", "left", "right"). - fill: How the widget should fill extra space ("x", "y", "both", "none"). - expand: Whether the widget expands to fill extra space (0/1 or False/True). - anchor: Where to place the widget if it does not fill the space. - padx, pady: External padding around the widget. - ipadx, ipady: Internal padding inside the widget. - before, after: Pack relative to another widget.

{}

Returns:

Type Description
Self

Self for method chaining.

pack_configure

pack_configure(
    cnf: dict[str, Any] | None = None, **kw: Any
) -> Self

Alias for pack().

Parameters:

Name Type Description Default
cnf dict[str, Any] | None

Optional dict of pack options.

None
**kw Any

Pack options (see pack).

{}

Returns:

Type Description
Self

Self for method chaining.

pack_forget

pack_forget() -> Self

Unmap this widget and forget its pack configuration.

The widget is removed from the layout, and its previous pack options are discarded.

Returns:

Type Description
Self

Self for method chaining.

pack_info

pack_info() -> dict[str, Any]

Return this widget's current pack configuration.

Returns:

Type Description
dict[str, Any]

A dict containing the current pack options for this widget

dict[str, Any]

(side, fill, expand, padx, pady, etc.).

pack_propagate

pack_propagate(flag: bool | None = None) -> bool | None

Get or set pack geometry propagation for this container.

When propagation is enabled (default), the container may resize itself to fit the size requests of its children.

Parameters:

Name Type Description Default
flag bool | None

True/False to enable/disable propagation. If None, acts as a getter.

None

Returns:

Type Description
bool | None

When queried, returns the current propagation flag. When set, returns None.

pack_slaves

pack_slaves() -> list[Any]

Return the widgets managed by pack in this container.

Returns:

Type Description
list[Any]

A list of child widgets managed by pack (in packing order).