Skip to content

Gtk.BoxLayout

class — extends LayoutManager, Orientable

Arranges children in a single row or column.

Whether it is a row or column depends on the value of its Orientable.orientation property. Within the other dimension all children all allocated the same size. The GtkBoxLayout will respect the Widget.halign and Widget.valign properties of each child widget.

If you want all children to be assigned the same size, you can use the BoxLayout.homogeneous property.

If you want to specify the amount of space placed between each child, you can use the BoxLayout.spacing property.

Constructors

new

@classmethod
def new(cls, orientation: Orientation | int) -> LayoutManager

Creates a new GtkBoxLayout.

Parameters:

  • orientation — the orientation for the new layout

Methods

get_baseline_child

def get_baseline_child(self) -> int

Gets the value set by BoxLayout.set_baseline_child.

get_baseline_position

def get_baseline_position(self) -> BaselinePosition

Gets the value set by BoxLayout.set_baseline_position.

get_homogeneous

def get_homogeneous(self) -> bool

Returns whether the layout is set to be homogeneous.

get_spacing

def get_spacing(self) -> int

Returns the space that box_layout puts between children.

set_baseline_child

def set_baseline_child(self, child: int) -> None

Sets the index of the child that determines the baseline in vertical layout.

Parameters:

  • child — the child position, or -1

set_baseline_position

def set_baseline_position(self, position: BaselinePosition | int) -> None

Sets the baseline position of a box layout.

The baseline position affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then the given position is used to allocate the baseline within the extra space available.

Parameters:

  • position — a GtkBaselinePosition

set_homogeneous

def set_homogeneous(self, homogeneous: bool) -> None

Sets whether the box layout will allocate the same size to all children.

Parameters:

  • homogeneousTrue to set the box layout as homogeneous

set_spacing

def set_spacing(self, spacing: int) -> None

Sets how much spacing to put between children.

Parameters:

  • spacing — the spacing to apply between children

Properties

baseline_child

baseline_child: int  # read/write

The child that determines the baseline of the box in vertical layout.

If the child does baseline positioning, then its baseline is lined up with the baseline of the box. If it doesn't, then the bottom edge of the child is used.

baseline_position

baseline_position: BaselinePosition | int  # read/write

The position of the allocated baseline within the extra space allocated to each child.

This property is only relevant for horizontal layouts containing at least one child with a baseline alignment.

homogeneous

homogeneous: bool  # read/write

Whether the box layout should distribute the available space equally among the children.

spacing

spacing: int  # read/write

The space to put between the children.