1.16 <GtkBox>

Class: <GtkBox>

It derives from <GtkWidget>.

Arranges child widgets into 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 are allocated the same size. The widget:halign and widget:valign properties can be used on the children to influence their allocation.

Use repeated calls to box:append to pack widgets into a <GtkBox> from start to end. Use box:remove to remove widgets from the <GtkBox>. box:insert-child-after can be used to add a child at a particular position.

Use box:set-homogeneous to specify whether or not all children of the <GtkBox> are forced to get the same amount of space.

Use box:set-spacing to determine how much space will be minimally placed between all children in the <GtkBox>. Note that spacing is added between the children.

Use box:reorder-child-after to move a child to a different place in the box.

CSS nodes

<GtkBox> uses a single CSS node with name box.

Accessibility

Until GTK 4.10, <GtkBox> used the Gtk.AccessibleRole.group role.

Starting from GTK 4.12, <GtkBox> uses the Gtk.AccessibleRole.generic role.

Fields

parent-instance

Properties

Property: box:baseline-child self

The position of the child that determines the baseline.

This is only relevant if the box is in vertical orientation.

Its value is a 32-bit integer.

Set it with (set! (box:baseline-child self) value).

Property: box:baseline-position self

How to position baseline-aligned widgets if extra space is available.

Its value is a <GtkBaselinePosition> (or, to set it, one of its symbols).

Set it with (set! (box:baseline-position self) value).

Property: box:homogeneous self

Whether the children should all be the same size.

Its value is a boolean.

Set it with (set! (box:homogeneous self) value).

Property: box:spacing self

The amount of space between children.

Its value is a 32-bit integer.

Set it with (set! (box:spacing self) value).

Procedures

Method: box:append self child
Method: append self child

Adds a child at the end.

self

Passed: a <GtkBox>.

a box

child

Passed: a <GtkWidget>.

the widget to append

Method: box:get-baseline-child self ⇒ %return
Method: get-baseline-child self ⇒ %return

Gets the value set by box:set-baseline-child.

self

Passed: a <GtkBox>.

a box

%return

Returned: a 32-bit integer.

the baseline child

Method: box:get-baseline-position self ⇒ %return
Method: get-baseline-position self ⇒ %return

Gets the value set by box:set-baseline-position.

self

Passed: a <GtkBox>.

a box

%return

Returned: a <GtkBaselinePosition>.

the baseline position

Method: box:get-homogeneous? self ⇒ %return
Method: get-homogeneous? self ⇒ %return

Returns whether the box is homogeneous.

In a homogeneous box all children are the same size.

self

Passed: a <GtkBox>.

a box

%return

Returned: a boolean.

true if the box is homogeneous

Method: box:get-spacing self ⇒ %return
Method: get-spacing self ⇒ %return

Gets the value set by box:set-spacing.

self

Passed: a <GtkBox>.

a box

%return

Returned: a 32-bit integer.

spacing between children

Method: box:insert-child-after self child [sibling]
Method: insert-child-after self child [sibling]

Inserts a child at a specific position.

The child is added after sibling in the list of self children.

If sibling is NULL, the child is placed at the beginning.

self

Passed: a <GtkBox>.

a box

child

Passed: a <GtkWidget>.

the widget to insert

sibling

Passed, or left out: a <GtkWidget>, or #f.

the sibling after which to insert child

Procedure: box:new orientation spacing ⇒ %return

Creates a new box.

orientation

Passed: a <GtkOrientation>, or one of its symbols.

the box’s orientation

spacing

Passed: a 32-bit integer.

the number of pixels to place between children

%return

Returned: a <GtkWidget>.

a new <GtkBox>.

Method: box:prepend self child
Method: prepend self child

Adds a child at the beginning.

self

Passed: a <GtkBox>.

a box

child

Passed: a <GtkWidget>.

the widget to prepend

Method: box:remove self child
Method: remove self child

Removes a child widget from the box.

The child must have been added before with box:append, box:prepend, or box:insert-child-after.

self

Passed: a <GtkBox>.

a box

child

Passed: a <GtkWidget>.

the child to remove

Method: box:reorder-child-after self child [sibling]
Method: reorder-child-after self child [sibling]

Moves a child to a different position.

The child is moved to the position after sibling in the list of self children.

If sibling is NULL, the child is placed at the beginning.

self

Passed: a <GtkBox>.

a box

child

Passed: a <GtkWidget>.

the widget to move, must be a child of self

sibling

Passed, or left out: a <GtkWidget>, or #f.

the sibling to move child after

Method: box:set-baseline-child self child
Method: set-baseline-child self child

Sets the baseline child of a box.

This affects only vertical boxes.

self

Passed: a <GtkBox>.

a box

child

Passed: a 32-bit integer.

a child position, or -1

Method: box:set-baseline-position self position
Method: set-baseline-position self position

Sets the baseline position of a box.

This 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 position is used to allocate the baseline with respect to the extra space available.

self

Passed: a <GtkBox>.

a box

position

Passed: a <GtkBaselinePosition>, or one of its symbols.

the baseline position

Method: box:set-homogeneous self homogeneous
Method: set-homogeneous self homogeneous

Sets whether or not all children are given equal space in the box.

self

Passed: a <GtkBox>.

a box

homogeneous

Passed: a boolean.

true to create equal allotments, false for variable allotments

Method: box:set-spacing self spacing
Method: set-spacing self spacing

Sets the number of pixels to place between children.

self

Passed: a <GtkBox>.

a box

spacing

Passed: a 32-bit integer.

the number of pixels to put between children