gtk.box

Module for [Box] class

Types 3

The [gtk.box.Box] widget arranges child widgets into a single row or column.

!An example GtkBox

Whether it is a row or column depends on the value of its [gtk.orientable.Orientable.orientation] property. Within the other dimension, all children are allocated the same size. Of course, the [gtk.widget.Widget.halign] and [gtk.widget.Widget.valign] properties can be used on the children to influence their allocation.

Use repeated calls to [gtk.box.Box.append] to pack widgets into a [gtk.box.Box] from start to end. Use [gtk.box.Box.remove] to remove widgets from the [gtk.box.Box]. [gtk.box.Box.insertChildAfter] can be used to add a child at a particular position.

Use [gtk.box.Box.setHomogeneous] to specify whether or not all children of the [gtk.box.Box] are forced to get the same amount of space.

Use [gtk.box.Box.setSpacing] to determine how much space will be minimally placed between all children in the [gtk.box.Box]. Note that spacing is added

between the children.

Use [gtk.box.Box.reorderChildAfter] to move a child to a different place in the box.

CSS nodes

[gtk.box.Box] uses a single CSS node with name box.

Accessibility

Until GTK 4.10, [gtk.box.Box] used the [gtk.types.AccessibleRole.Group] role.

Starting from GTK 4.12, [gtk.box.Box] uses the [gtk.types.AccessibleRole.Generic] role.

Methods
GType _gType() @property
Box self()Returns `this`, for use in `with` statements.
BoxGidBuilder builder()Get builder for [gtk.box.Box] Returns: New builder object
int baselineChild() @propertyGet `baselineChild` property. Returns: The child that determines the baseline, in vertical orientation.
void baselineChild(int propval) @propertySet `baselineChild` property. Params: propval = The child that determines the baseline, in vertical orientation.
gtk.types.BaselinePosition baselinePosition() @propertyGet `baselinePosition` property. Returns: The position of the baseline aligned widgets if extra space is available.
void baselinePosition(gtk.types.BaselinePosition propval) @propertySet `baselinePosition` property. Params: propval = The position of the baseline aligned widgets if extra space is available.
bool homogeneous() @propertyGet `homogeneous` property. Returns: Whether the children should all be the same size.
void homogeneous(bool propval) @propertySet `homogeneous` property. Params: propval = Whether the children should all be the same size.
int spacing() @propertyGet `spacing` property. Returns: The amount of space between children.
void spacing(int propval) @propertySet `spacing` property. Params: propval = The amount of space between children.
void append(gtk.widget.Widget child)Adds child as the last child to box.
int getBaselineChild()Gets the value set by [gtk.box.Box.setBaselineChild]. Returns: the baseline child
gtk.types.BaselinePosition getBaselinePosition()Gets the value set by [gtk.box.Box.setBaselinePosition]. Returns: the baseline position
bool getHomogeneous()Returns whether the box is homogeneous (all children are the same size). Returns: true if the box is homogeneous.
int getSpacing()Gets the value set by [gtk.box.Box.setSpacing]. Returns: spacing between children
void insertChildAfter(gtk.widget.Widget child, gtk.widget.Widget sibling = null)Inserts child in the position after sibling in the list of box children.
void prepend(gtk.widget.Widget child)Adds child as the first child to box.
void remove(gtk.widget.Widget child)Removes a child widget from box.
void reorderChildAfter(gtk.widget.Widget child, gtk.widget.Widget sibling = null)Moves child to the position after sibling in the list of box children.
void setBaselineChild(int child)Sets the baseline child of a box.
void setBaselinePosition(gtk.types.BaselinePosition position)Sets the baseline position of a box.
void setHomogeneous(bool homogeneous)Sets whether or not all children of box are given equal space in the box.
void setSpacing(int spacing)Sets the number of pixels to place between children of box.
Constructors
this(void * ptr, Flag!"Take" take)
this(gtk.types.Orientation orientation, int spacing)Creates a new [gtk.box.Box].
Methods
T baselineChild(int propval)Set `baselineChild` property. Params: propval = The child that determines the baseline, in vertical orientation. Returns: Builder instance for fluent chaining
T baselinePosition(gtk.types.BaselinePosition propval)Set `baselinePosition` property. Params: propval = The position of the baseline aligned widgets if extra space is available. Returns: Builder instance for fluent chaining
T homogeneous(bool propval)Set `homogeneous` property. Params: propval = Whether the children should all be the same size. Returns: Builder instance for fluent chaining
T spacing(int propval)Set `spacing` property. Params: propval = The amount of space between children. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.box.Box]

Methods