Gtk.Box¶
Example¶
 
- Subclasses:
Methods¶
- Inherited:
- Gtk.Widget (183), GObject.Object (37), Gtk.Accessible (17), Gtk.Buildable (1), Gtk.Orientable (2) 
- Structs:
| class | 
 | 
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | 
Virtual Methods¶
- Inherited:
- Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9) 
Properties¶
- Inherited:
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| r/w/en | |||
| r/w/en | |||
| r/w/en | |||
| r/w/en | 
Signals¶
- Inherited:
Fields¶
- Inherited:
| Name | Type | Access | Description | 
|---|---|---|---|
| parent_instance | r | 
Class Details¶
- class Gtk.Box(**kwargs)¶
- Bases:
- Abstract:
- No 
- Structure:
 - Arranges child widgets into a single row or column. - <picture> <source srcset=”box-dark.png” media=”(prefers-color-scheme: dark)”> <img alt=”An example - Gtk.Box" src=”box.png”> </picture>- Whether it is a row or column depends on the value of its [property`Gtk`.Orientable:orientation] property. Within the other dimension, all children are allocated the same size. The [property`Gtk`.Widget:halign] and [property`Gtk`.Widget:valign] properties can be used on the children to influence their allocation. - Use repeated calls to [method`Gtk`.Box.append] to pack widgets into a - GtkBoxfrom start to end. Use [method`Gtk`.Box.remove] to remove widgets from the- GtkBox. [method`Gtk`.Box.insert_child_after] can be used to add a child at a particular position.- Use [method`Gtk`.Box.set_homogeneous] to specify whether or not all children of the - GtkBoxare forced to get the same amount of space.- Use [method`Gtk`.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 [method`Gtk`.Box.reorder_child_after] to move a child to a different place in the box. - CSS nodes
 - GtkBoxuses a single CSS node with name box.- Accessibility
 - Until GTK 4.10, - GtkBoxused the [enum`Gtk`.AccessibleRole.group] role.- Starting from GTK 4.12, - GtkBoxuses the [enum`Gtk`.AccessibleRole.generic] role.- classmethod new(orientation, spacing)[source]¶
- Parameters:
- orientation ( - Gtk.Orientation) – the box’s orientation
- spacing ( - int) – the number of pixels to place between children
 
- Returns:
- a new - GtkBox.
- Return type:
 - Creates a new box. 
 - append(child)[source]¶
- Parameters:
- child ( - Gtk.Widget) – the widget to append
 - Adds a child at the end. 
 - get_baseline_child()[source]¶
- Returns:
- the baseline child 
- Return type:
 - Gets the value set by [method`Gtk`.Box.set_baseline_child]. - New in version 4.12. 
 - get_baseline_position()[source]¶
- Returns:
- the baseline position 
- Return type:
 - Gets the value set by [method`Gtk`.Box.set_baseline_position]. 
 - get_homogeneous()[source]¶
- Returns:
- true if the box is homogeneous 
- Return type:
 - Returns whether the box is homogeneous. - In a homogeneous box all children are the same size. 
 - get_spacing()[source]¶
- Returns:
- spacing between children 
- Return type:
 - Gets the value set by [method`Gtk`.Box.set_spacing]. 
 - insert_child_after(child, sibling)[source]¶
- Parameters:
- child ( - Gtk.Widget) – the widget to insert
- sibling ( - Gtk.Widgetor- None) – the sibling after which to insert child
 
 - 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.
 - prepend(child)[source]¶
- Parameters:
- child ( - Gtk.Widget) – the widget to prepend
 - Adds a child at the beginning. 
 - remove(child)[source]¶
- Parameters:
- child ( - Gtk.Widget) – the child to remove
 - Removes a child widget from the box. - The child must have been added before with [method`Gtk`.Box.append], [method`Gtk`.Box.prepend], or [method`Gtk`.Box.insert_child_after]. 
 - reorder_child_after(child, sibling)[source]¶
- Parameters:
- child ( - Gtk.Widget) – the widget to move, must be a child of self
- sibling ( - Gtk.Widgetor- None) – the sibling to move child after
 
 - 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.
 - set_baseline_child(child)[source]¶
- Parameters:
- child ( - int) – a child position, or -1
 - Sets the baseline child of a box. - This affects only vertical boxes. - New in version 4.12. 
 - set_baseline_position(position)[source]¶
- Parameters:
- position ( - Gtk.BaselinePosition) – the baseline 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. 
 
Property Details¶
- Gtk.Box.props.baseline_child¶
- Name:
- baseline-child
- Type:
- Default Value:
- -1
- Flags:
 - The position of the child that determines the baseline. - This is only relevant if the box is in vertical orientation. - New in version 4.12. 
- Gtk.Box.props.baseline_position¶
- Name:
- baseline-position
- Type:
- Default Value:
- Flags:
 - How to position baseline-aligned widgets if extra space is available. 
- Gtk.Box.props.homogeneous¶
- Name:
- homogeneous
- Type:
- Default Value:
- Flags:
 - Whether the children should all be the same size. 
- Gtk.Box.props.spacing¶
- Name:
- spacing
- Type:
- Default Value:
- 0
- Flags:
 - The amount of space between children.