Gtk.Box¶
- Subclasses:
Gtk.AppChooserWidget
,Gtk.ButtonBox
,Gtk.ColorChooserWidget
,Gtk.ColorSelection
,Gtk.FileChooserButton
,Gtk.FileChooserWidget
,Gtk.FontChooserWidget
,Gtk.FontSelection
,Gtk.HBox
,Gtk.InfoBar
,Gtk.RecentChooserWidget
,Gtk.ShortcutLabel
,Gtk.ShortcutsGroup
,Gtk.ShortcutsSection
,Gtk.ShortcutsShortcut
,Gtk.StackSwitcher
,Gtk.Statusbar
,Gtk.VBox
Methods¶
- Inherited:
Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Orientable (2)
- Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
The position of the baseline aligned widgets if extra space is available |
||
r/w/en |
Whether the children should all be the same size |
||
r/w/en |
The amount of space between children |
Child Properties¶
Name |
Type |
Default |
Flags |
Short Description |
---|---|---|---|---|
|
r/w |
Whether the child should receive extra space when the parent grows |
||
|
r/w |
Whether extra space given to the child should be allocated to the child or used as padding |
||
|
r/w |
A |
||
|
|
r/w |
Extra space to put between the child and its neighbors, in pixels |
|
|
|
r/w |
The index of the child in the parent |
Style Properties¶
- Inherited:
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
container |
r |
Class Details¶
- class Gtk.Box(*args, **kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The
Gtk.Box
widget arranges child widgets into a single row or column, depending upon the value of itsGtk.Orientable
:orientation
property. Within the other dimension, all children are allocated the same size. Of course, theGtk.Widget
:halign
andGtk.Widget
:valign
properties can be used on the children to influence their allocation.Gtk.Box
uses a notion of packing. Packing refers to adding widgets with reference to a particular position in aGtk.Container
. For aGtk.Box
, there are two reference positions: the start and the end of the box. For a verticalGtk.Box
, the start is defined as the top of the box and the end is defined as the bottom. For a horizontalGtk.Box
the start is defined as the left side and the end is defined as the right side.Use repeated calls to
Gtk.Box.pack_start
() to pack widgets into aGtk.Box
from start to end. UseGtk.Box.pack_end
() to add widgets from end to start. You may intersperse these calls and add widgets from both ends of the sameGtk.Box
.Because
Gtk.Box
is aGtk.Container
, you may also useGtk.Container.add
() to insert widgets into the box, and they will be packed with the default values for expand and fill child properties. UseGtk.Container.remove
() to remove widgets from theGtk.Box
.Use
Gtk.Box.set_homogeneous
() to specify whether or not all children of theGtk.Box
are forced to get the same amount of space.Use
Gtk.Box.set_spacing
() to determine how much space will be minimally placed between all children in theGtk.Box
. Note that spacing is added between the children, while padding added byGtk.Box.pack_start
() orGtk.Box.pack_end
() is added on either side of the widget it belongs to.Use
Gtk.Box.reorder_child
() to move aGtk.Box
child to a different place in the box.Use
Gtk.Box.set_child_packing
() to reset the expand, fill and padding child properties. UseGtk.Box.query_child_packing
() to query these fields.- CSS nodes
Gtk.Box
uses a single CSS node with name box.In horizontal orientation, the nodes of the children are always arranged from left to right. So
:first-child
will always select the leftmost child, regardless of text direction.- classmethod new(orientation, spacing)[source]¶
- Parameters:
orientation (
Gtk.Orientation
) – the box’s orientation.spacing (
int
) – the number of pixels to place by default between children.
- Returns:
a new
Gtk.Box
.- Return type:
Creates a new
Gtk.Box
.New in version 3.0.
- get_baseline_position()[source]¶
- Returns:
the baseline position
- Return type:
Gets the value set by
Gtk.Box.set_baseline_position
().New in version 3.10.
- get_center_widget()[source]¶
- Returns:
the center widget or
None
in case no center widget is set.- Return type:
Gtk.Widget
orNone
Retrieves the center widget of the box.
New in version 3.12.
- get_homogeneous()[source]¶
-
Returns whether the box is homogeneous (all children are the same size). See
Gtk.Box.set_homogeneous
().
- get_spacing()[source]¶
- Returns:
spacing between children
- Return type:
Gets the value set by
Gtk.Box.set_spacing
().
- pack_end(child, expand, fill, padding)[source]¶
- Parameters:
child (
Gtk.Widget
) – theGtk.Widget
to be added to selfexpand (
bool
) –True
if the new child is to be given extra space allocated to self. The extra space will be divided evenly between all children of self that use this optionfill (
bool
) –True
if space given to child by the expand option is actually allocated to child, rather than just padding it. This parameter has no effect if expand is set toFalse
. A child is always allocated the full height of a horizontalGtk.Box
and the full width of a verticalGtk.Box
. This option affects the other dimensionpadding (
int
) – extra space in pixels to put between this child and its neighbors, over and above the global amount specified byGtk.Box
:spacing
property. If child is a widget at one of the reference ends of self, then padding pixels are also put between child and the reference edge of self
Adds child to self, packed with reference to the end of self. The child is packed after (away from end of) any other child packed with reference to the end of self.
- pack_start(child, expand, fill, padding)[source]¶
- Parameters:
child (
Gtk.Widget
) – theGtk.Widget
to be added to selfexpand (
bool
) –True
if the new child is to be given extra space allocated to self. The extra space will be divided evenly between all children that use this optionfill (
bool
) –True
if space given to child by the expand option is actually allocated to child, rather than just padding it. This parameter has no effect if expand is set toFalse
. A child is always allocated the full height of a horizontalGtk.Box
and the full width of a verticalGtk.Box
. This option affects the other dimensionpadding (
int
) – extra space in pixels to put between this child and its neighbors, over and above the global amount specified byGtk.Box
:spacing
property. If child is a widget at one of the reference ends of self, then padding pixels are also put between child and the reference edge of self
Adds child to self, packed with reference to the start of self. The child is packed after any other child packed with reference to the start of self.
- query_child_packing(child)[source]¶
- Parameters:
child (
Gtk.Widget
) – theGtk.Widget
of the child to query- Returns:
- expand:
pointer to return location for expand child property
- fill:
pointer to return location for fill child property
- padding:
pointer to return location for padding child property
- pack_type:
pointer to return location for pack-type child property
- Return type:
(expand:
bool
, fill:bool
, padding:int
, pack_type:Gtk.PackType
)
Obtains information about how child is packed into self.
- reorder_child(child, position)[source]¶
- Parameters:
child (
Gtk.Widget
) – theGtk.Widget
to moveposition (
int
) – the new position for child in the list of children of self, starting from 0. If negative, indicates the end of the list
Moves child to a new position in the list of self children. The list contains widgets packed
Gtk.PackType.START
as well as widgets packedGtk.PackType.END
, in the order that these widgets were added to self.A widget’s position in the self children list determines where the widget is packed into self. A child widget at some position in the list will be packed just after all other widgets of the same packing type that appear earlier in the list.
- set_baseline_position(position)[source]¶
- Parameters:
position (
Gtk.BaselinePosition
) – aGtk.BaselinePosition
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 wrt the extra space available.
New in version 3.10.
- set_center_widget(widget)[source]¶
- Parameters:
widget (
Gtk.Widget
orNone
) – the widget to center
Sets a center widget; that is a child widget that will be centered with respect to the full width of the box, even if the children at either side take up different amounts of space.
New in version 3.12.
- set_child_packing(child, expand, fill, padding, pack_type)[source]¶
- Parameters:
child (
Gtk.Widget
) – theGtk.Widget
of the child to setexpand (
bool
) – the new value of the expand child propertyfill (
bool
) – the new value of the fill child propertypadding (
int
) – the new value of the padding child propertypack_type (
Gtk.PackType
) – the new value of the pack-type child property
Sets the way child is packed into self.
Property Details¶
- 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