Gtk.CenterBox

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget Gtk.Orientable Gtk.Orientable GObject.GInterface->Gtk.Orientable GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.CenterBox Gtk.CenterBox Gtk.ConstraintTarget->Gtk.Widget Gtk.Orientable->Gtk.CenterBox Gtk.Widget->Gtk.CenterBox

Example

../_images/CenterBox.png
Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Orientable (2)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new ()

get_baseline_position ()

get_center_widget ()

get_end_widget ()

get_shrink_center_last ()

get_start_widget ()

set_baseline_position (position)

set_center_widget (child)

set_end_widget (child)

set_shrink_center_last (shrink_center_last)

set_start_widget (child)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1), Gtk.Orientable (1)

Name

Type

Flags

Short Description

baseline-position

Gtk.BaselinePosition

r/w/en

center-widget

Gtk.Widget

r/w/en

end-widget

Gtk.Widget

r/w/en

shrink-center-last

bool

r/w/en

start-widget

Gtk.Widget

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class Gtk.CenterBox(**kwargs)
Bases:

Gtk.Widget, Gtk.Orientable

Abstract:

No

Structure:

Gtk.CenterBoxClass

GtkCenterBox arranges three children in a row, keeping the middle child centered as well as possible.

An example Gtk.CenterBox

To add children to GtkCenterBox, use [method`Gtk`.CenterBox.set_start_widget], [method`Gtk`.CenterBox.set_center_widget] and [method`Gtk`.CenterBox.set_end_widget].

The sizing and positioning of children can be influenced with the align and expand properties of the children.

Gtk.CenterBox as Gtk.Buildable

The GtkCenterBox implementation of the GtkBuildable interface supports placing children in the 3 positions by specifying “start”, “center” or “end” as the “type” attribute of a <child> element.

CSS nodes

GtkCenterBox uses a single CSS node with the name “box”,

The first child of the GtkCenterBox will be allocated depending on the text direction, i.e. in left-to-right layouts it will be allocated on the left and in right-to-left layouts on the right.

In vertical orientation, the nodes of the children are arranged from top to bottom.

Accessibility

Until GTK 4.10, GtkCenterBox used the GTK_ACCESSIBLE_ROLE_GROUP role.

Starting from GTK 4.12, GtkCenterBox uses the GTK_ACCESSIBLE_ROLE_GENERIC role.

classmethod new()[source]
Returns:

the new GtkCenterBox.

Return type:

Gtk.Widget

Creates a new GtkCenterBox.

get_baseline_position()[source]
Returns:

the baseline position

Return type:

Gtk.BaselinePosition

Gets the value set by Gtk.CenterBox.set_baseline_position().

get_center_widget()[source]
Returns:

the center widget.

Return type:

Gtk.Widget or None

Gets the center widget, or None if there is none.

get_end_widget()[source]
Returns:

the end widget.

Return type:

Gtk.Widget or None

Gets the end widget, or None if there is none.

get_shrink_center_last()[source]
Returns:

whether to shrink the center widget after others

Return type:

bool

Gets whether self shrinks the center widget after other children.

New in version 4.12.

get_start_widget()[source]
Returns:

the start widget.

Return type:

Gtk.Widget or None

Gets the start widget, or None if there is none.

set_baseline_position(position)[source]
Parameters:

position (Gtk.BaselinePosition) – a GtkBaselinePosition

Sets the baseline position of a center 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.

set_center_widget(child)[source]
Parameters:

child (Gtk.Widget or None) – the new center widget

Sets the center widget.

To remove the existing center widget, pass None.

set_end_widget(child)[source]
Parameters:

child (Gtk.Widget or None) – the new end widget

Sets the end widget.

To remove the existing end widget, pass None.

set_shrink_center_last(shrink_center_last)[source]
Parameters:

shrink_center_last (bool) – whether to shrink the center widget after others

Sets whether to shrink the center widget after other children.

By default, when there’s no space to give all three children their natural widths, the start and end widgets start shrinking and the center child keeps natural width until they reach minimum width.

If set to FALSE, start and end widgets keep natural width and the center widget starts shrinking instead.

New in version 4.12.

set_start_widget(child)[source]
Parameters:

child (Gtk.Widget or None) – the new start widget

Sets the start widget.

To remove the existing start widget, pass None.

Property Details

Gtk.CenterBox.props.baseline_position
Name:

baseline-position

Type:

Gtk.BaselinePosition

Default Value:

Gtk.BaselinePosition.CENTER

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The position of the baseline aligned widget if extra space is available.

Gtk.CenterBox.props.center_widget
Name:

center-widget

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The widget that is placed at the center position.

New in version 4.10.

Gtk.CenterBox.props.end_widget
Name:

end-widget

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The widget that is placed at the end position.

In vertical orientation, the end position is at the bottom. In horizontal orientation, the end position is at the trailing edge wrt. to the text direction.

New in version 4.10.

Gtk.CenterBox.props.shrink_center_last
Name:

shrink-center-last

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to shrink the center widget after other children.

By default, when there’s no space to give all three children their natural widths, the start and end widgets start shrinking and the center child keeps natural width until they reach minimum width.

If set to FALSE, start and end widgets keep natural width and the center widget starts shrinking instead.

New in version 4.12.

Gtk.CenterBox.props.start_widget
Name:

start-widget

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The widget that is placed at the start position.

In vertical orientation, the start position is at the top. In horizontal orientation, the start position is at the leading edge wrt. to the text direction.

New in version 4.10.