Gtk.Box¶
Example¶
- Subclasses:
Methods¶
- Inherited:
Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), 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:
The
GtkBox
widget arranges child widgets into a single row or column.An example
Gtk.Box
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. Of course, 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
GtkBox
from start to end. Use [method`Gtk`.Box.remove] to remove widgets from theGtkBox
. [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
GtkBox
are 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
GtkBox
uses a single CSS node with name box.- Accessibility
Until GTK 4.10,
GtkBox
used theGTK_ACCESSIBLE_ROLE_GROUP
role.Starting from GTK 4.12,
GtkBox
uses theGTK_ACCESSIBLE_ROLE_GENERIC
role.- classmethod new(orientation, spacing)[source]¶
- Parameters:
orientation (
Gtk.Orientation
) – the box’s orientationspacing (
int
) – the number of pixels to place by default between children
- Returns:
a new
GtkBox
.- Return type:
Creates a new
GtkBox
.
- append(child)[source]¶
- Parameters:
child (
Gtk.Widget
) – theGtkWidget
to append
Adds child as the last child to self.
- get_baseline_child()[source]¶
- Returns:
the baseline child
- Return type:
Gets the value set by
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
Gtk.Box.set_baseline_position
().
- get_spacing()[source]¶
- Returns:
spacing between children
- Return type:
Gets the value set by
Gtk.Box.set_spacing
().
- insert_child_after(child, sibling)[source]¶
- Parameters:
child (
Gtk.Widget
) – theGtkWidget
to insertsibling (
Gtk.Widget
orNone
) – the sibling after which to insert child
Inserts child in the position after sibling in the list of self children.
If sibling is
None
, insert child at the first position.
- prepend(child)[source]¶
- Parameters:
child (
Gtk.Widget
) – theGtkWidget
to prepend
Adds child as the first child to self.
- remove(child)[source]¶
- Parameters:
child (
Gtk.Widget
) – the child to remove
Removes a child widget from self.
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
) – theGtkWidget
to move, must be a child of selfsibling (
Gtk.Widget
orNone
) – the sibling to move child after
Moves child to the position after sibling in the list of self children.
If sibling is
None
, move child to the first position.
- set_baseline_child(child)[source]¶
- Parameters:
child (
int
) – a child, 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
) – aGtkBaselinePosition
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 child that determines the baseline, in vertical orientation.
New in version 4.12.
- Gtk.Box.props.baseline_position¶
- Name:
baseline-position
- Type:
- Default Value:
- Flags:
The position of the 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.