Pack#

The pack geometry manager places a widget by stacking it against one side of its parent. This page is the method spec; Arranging widgets teaches when to reach for pack.

In ttkbootstrap pack (and pack_configure) return the widget, so construction and placement can be chained.

The canonical upstream reference is the Tk pack manual page (Tcl 8.6).

Options#

Every option below is a keyword argument to pack().

Option

Type

Description

side

str

The side of the remaining space the widget stacks against: "top" (default), "bottom", "left", or "right".

fill

str

Stretch the widget to fill its slot: "x", "y", "both", or "none" (default).

expand

bool

Claim a share of the parent’s leftover space — the slot grows; pair with fill so the widget grows with it.

anchor

str

Where the widget sits inside its slot when it does not fill it: "center", a side ("n"/"s"/"e"/"w"), or a corner ("ne", "sw", …).

padx
pady

int | tuple

External space around the widget, in pixels. A (left, right) / (top, bottom) tuple pads the two sides differently.

ipadx
ipady

int

Internal padding added to the widget’s own size, in pixels.

before
after

Widget

Insert the widget into the packing order relative to a sibling that is already packed.

in_

Widget

Pack inside a container other than the parent (the container must be the parent or one of its descendants). Rarely needed.

Methods#

pack(**options)

Place the widget against a side of its parent, using the options above. Alias: pack_configure.

Returns:

the widget (ttkbootstrap), for chaining.

pack_forget()

Unmap the widget; it keeps existing and can be re-packed later.

Returns:

None.

pack_info()

Return the widget’s current pack options.

Return type:

dict

pack_propagate(flag=None)

Get or set whether this container shrinks/grows to fit the widgets packed inside it. Call on the parent. Set False to keep a fixed size regardless of children.

Parameters:

flag (bool) – the new setting; omit to query the current one.

Returns:

the current setting when queried, else None.

pack_slaves()

Return the widgets this container manages with pack, in packing order. Call on the parent.

Return type:

list