Adw.WrapBox¶
- Subclasses:
None
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 |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Adw.WrapBox(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A box-like widget that can wrap into multiple lines.
<picture> <source srcset=”wrap-box-dark.png” media=”(prefers-color-scheme: dark)”> <img src=”wrap-box.png” alt=”wrap-box”> </picture>
AdwWrapBox
is similar to [class`Gtk`.Box], but can wrap lines when the widgets cannot fit otherwise. Unlike [class`Gtk`.FlowBox], the children aren’t arranged into a grid and behave more like words in a wrapping label.Like
GtkBox
,AdwWrapBox
is orientable and has spacing:[property`WrapBox`:py:data::child-spacing<Adw.WrapBox.props.child_spacing>] between children in the same line;
[property`WrapBox`:py:data::line-spacing<Adw.WrapBox.props.line_spacing>] between lines.
::: note Unlike
GtkBox
,AdwWrapBox
cannot follow the CSSborder-spacing
property.Use the [property`WrapBox`:py:data::natural-line-length<Adw.WrapBox.props.natural_line_length>] property to determine the layout’s natural size, e.g. when using it in a [class`Gtk`.Popover].
Normally, a horizontal
AdwWrapBox
wraps left to right and top to bottom for left-to-right languages. Both of these directions can be reversed, using the [property`WrapBox`:py:data::pack-direction<Adw.WrapBox.props.pack_direction>] and [property`WrapBox`:py:data::wrap-reverse<Adw.WrapBox.props.wrap_reverse>] properties. Additionally, the alignment of each line can be controlled with the [property`WrapBox`:py:data::align<Adw.WrapBox.props.align>] property.Lines can be justified using the [property`WrapBox`:py:data::justify<Adw.WrapBox.props.justify>] property, filling the entire line by either increasing child size or spacing depending on the value. Set [property`WrapBox`:py:data::justify-last-line<Adw.WrapBox.props.justify_last_line>] to justify the last line as well.
By default,
AdwWrapBox
wraps as soon as the previous line cannot fit any more children without shrinking them past their natural size. Set [property`WrapBox`:py:data::wrap-policy<Adw.WrapBox.props.wrap_policy>] to [enum`Adw`.WrapPolicy.MINIMUM] to only wrap once all the children in the previous line have been shrunk to their minimum size.To make each line take the same amount of space, set [property`WrapBox`:py:data::line-homogeneous<Adw.WrapBox.props.line_homogeneous>] to
TRUE
.Spacing and natural line length can scale with the text scale factor, use the [property`WrapBox`:py:data::child-spacing-unit<Adw.WrapBox.props.child_spacing_unit>], [property`WrapBox`:py:data::line-spacing-unit<Adw.WrapBox.props.line_spacing_unit>] and/or [property`WrapBox`:py:data::natural-line-length-unit<Adw.WrapBox.props.natural_line_length_unit>] properties to enable that behavior.
See [class`WrapLayout`].
- CSS nodes
AdwWrapBox
uses a single CSS node with namewrap-box
.- Accessibility
AdwWrapBox
uses theGTK_ACCESSIBLE_ROLE_GROUP
role.New in version 1.7.
- classmethod new()¶
- Returns:
the newly created
AdwWrapBox
- Return type:
Creates a new
AdwWrapBox
.New in version 1.7.
- append(child)¶
- Parameters:
child (
Gtk.Widget
) – the widget to append
Adds child as the last child to self.
New in version 1.7.
- get_align()¶
- Returns:
the child alignment
- Return type:
Gets the alignment of the children within each line.
New in version 1.7.
- get_child_spacing()¶
- Returns:
spacing between widgets on the same line
- Return type:
Gets spacing between widgets on the same line.
New in version 1.7.
- get_child_spacing_unit()¶
- Returns:
the length unit
- Return type:
Gets the length unit for child spacing.
New in version 1.7.
- get_justify()¶
- Returns:
the justify mode
- Return type:
Gets whether and how each complete line is stretched to fill the entire widget.
New in version 1.7.
- get_justify_last_line()¶
- Returns:
whether the last line is justified
- Return type:
Gets whether the last line should be stretched to fill the entire widget.
New in version 1.7.
- get_line_homogeneous()¶
- Returns:
whether lines should be homogeneous
- Return type:
Gets whether all lines should take the same amount of space.
New in version 1.7.
- get_line_spacing()¶
- Returns:
the line spacing
- Return type:
Gets the spacing between lines.
See [property`WrapBox`:py:data::line-spacing-unit<Adw.WrapBox.props.line_spacing_unit>].
New in version 1.7.
- get_line_spacing_unit()¶
- Returns:
the length unit
- Return type:
Gets the length unit for line spacing.
New in version 1.7.
- get_natural_line_length()¶
- Returns:
the natural length
- Return type:
Gets the natural size for each line.
New in version 1.7.
- get_natural_line_length_unit()¶
- Returns:
the length unit
- Return type:
Gets the length unit for line spacing.
New in version 1.7.
- get_pack_direction()¶
- Returns:
the line direction
- Return type:
Gets the direction children are packed in each line.
New in version 1.7.
- get_wrap_policy()¶
- Returns:
the wrap policy
- Return type:
Gets the policy for line wrapping.
New in version 1.7.
- get_wrap_reverse()¶
- Returns:
whether wrap direction is reversed
- Return type:
Gets whether wrap direction is reversed.
New in version 1.7.
- insert_child_after(child, sibling)¶
- Parameters:
child (
Gtk.Widget
) – the widget 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
NULL
, inserts child at the first position.New in version 1.7.
- prepend(child)¶
- Parameters:
child (
Gtk.Widget
) – the widget to prepend
Adds child as the first child to self.
New in version 1.7.
- remove(child)¶
- Parameters:
child (
Gtk.Widget
) – the child to remove
Removes a child widget from self.
The child must have been added before with [method`Adw`.WrapBox.append], [method`Adw`.WrapBox.prepend], or [method`Adw`.WrapBox.insert_child_after].
New in version 1.7.
- reorder_child_after(child, sibling)¶
- Parameters:
child (
Gtk.Widget
) – the widget 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
NULL
, moves child to the first position.New in version 1.7.
- set_align(align)¶
- Parameters:
align (
float
) – the child alignment
Sets the alignment of the children within each line.
0 means the children are placed at the start of the line, 1 means they are placed at the end of the line. 0.5 means they are placed in the middle of the line.
Alignment is only used when [property`WrapBox`:py:data::justify<Adw.WrapBox.props.justify>] is set to
ADW_JUSTIFY_NONE
, or on the last line when the [property`WrapBox`:py:data::justify-last-line<Adw.WrapBox.props.justify_last_line>] isFALSE
.New in version 1.7.
- set_child_spacing(child_spacing)¶
- Parameters:
child_spacing (
int
) – the child spacing
Sets the spacing between widgets on the same line.
See [property`WrapBox`:py:data::child-spacing-unit<Adw.WrapBox.props.child_spacing_unit>].
New in version 1.7.
- set_child_spacing_unit(unit)¶
- Parameters:
unit (
Adw.LengthUnit
) – the length unit
Sets the length unit for child spacing.
Allows the spacing to vary depending on the text scale factor.
See [property`WrapBox`:py:data::child-spacing<Adw.WrapBox.props.child_spacing>].
New in version 1.7.
- set_justify(justify)¶
- Parameters:
justify (
Adw.JustifyMode
) – the justify mode
Determines whether and how each complete line should be stretched to fill the entire widget.
If set to
ADW_JUSTIFY_FILL
, each widget in the line will be stretched, keeping consistent spacing, so that the line fills the entire widget.If set to
ADW_JUSTIFY_SPREAD
, the spacing between widgets will be increased, keeping widget sizes intact. The first and last widget will be aligned with the beginning and end of the line. If the line only contains a single widget, it will be stretched regardless.If set to
ADW_JUSTIFY_NONE
, the line will not be stretched and the children will be placed together within the line, according to [property`WrapBox`:py:data::align<Adw.WrapBox.props.align>].By default this doesn’t affect the last line, as it will be incomplete. Use [property`WrapBox`:py:data::justify-last-line<Adw.WrapBox.props.justify_last_line>] to justify it as well.
New in version 1.7.
- set_justify_last_line(justify_last_line)¶
- Parameters:
justify_last_line (
bool
) – whether to justify the last line
Sets whether the last line should be stretched to fill the entire widget.
See [property`WrapBox`:py:data::justify<Adw.WrapBox.props.justify>].
New in version 1.7.
- set_line_homogeneous(homogeneous)¶
- Parameters:
homogeneous (
bool
) – whether lines should be homogeneous
Sets whether all lines should take the same amount of space.
New in version 1.7.
- set_line_spacing(line_spacing)¶
- Parameters:
line_spacing (
int
) – the line spacing
Sets the spacing between lines.
New in version 1.7.
- set_line_spacing_unit(unit)¶
- Parameters:
unit (
Adw.LengthUnit
) – the length unit
Sets the length unit for line spacing.
Allows the spacing to vary depending on the text scale factor.
See [property`WrapBox`:py:data::line-spacing<Adw.WrapBox.props.line_spacing>].
New in version 1.7.
- set_natural_line_length(natural_line_length)¶
- Parameters:
natural_line_length (
int
) – the natural length
Sets the natural size for each line.
It should be used to limit the line lengths, for example when used in popovers.
See [property`WrapBox`:py:data::natural-line-length-unit<Adw.WrapBox.props.natural_line_length_unit>].
New in version 1.7.
- set_natural_line_length_unit(unit)¶
- Parameters:
unit (
Adw.LengthUnit
) – the length unit
Sets the length unit for natural line length.
Allows the length to vary depending on the text scale factor.
See [property`WrapBox`:py:data::natural-line-length<Adw.WrapBox.props.natural_line_length>].
New in version 1.7.
- set_pack_direction(pack_direction)¶
- Parameters:
pack_direction (
Adw.PackDirection
) – the new line direction
Sets the direction children are packed in each line.
New in version 1.7.
- set_wrap_policy(wrap_policy)¶
- Parameters:
wrap_policy (
Adw.WrapPolicy
) – the new wrap policy
Sets the policy for line wrapping.
If set to
ADW_WRAP_NATURAL
, the box will wrap to the next line as soon as the previous line cannot fit any more children without shrinking them past their natural size.If set to
ADW_WRAP_MINIMUM
, the box will try to fit as many children into each line as possible, shrinking them down to their minimum size before wrapping to the next line.New in version 1.7.
- set_wrap_reverse(wrap_reverse)¶
- Parameters:
wrap_reverse (
bool
) – whether to reverse wrap direction
Sets whether wrap direction should be reversed.
By default, lines wrap downwards in a horizontal box, and towards the end in a vertical box. If set to
TRUE
, they wrap upwards or towards the start respectively.New in version 1.7.
Property Details¶
- Adw.WrapBox.props.align¶
- Name:
align
- Type:
- Default Value:
0.0
- Flags:
The alignment of the children within each line.
0 means the children are placed at the start of the line, 1 means they are placed at the end of the line. 0.5 means they are placed in the middle of the line.
Alignment is only used when [property`WrapBox`:py:data::justify<Adw.WrapBox.props.justify>] is set to
ADW_JUSTIFY_NONE
, or on the last line when the [property`WrapBox`:py:data::justify-last-line<Adw.WrapBox.props.justify_last_line>] isFALSE
.New in version 1.7.
- Adw.WrapBox.props.child_spacing¶
- Name:
child-spacing
- Type:
- Default Value:
0
- Flags:
The spacing between widgets on the same line.
See [property`WrapBox`:py:data::child-spacing-unit<Adw.WrapBox.props.child_spacing_unit>].
New in version 1.7.
- Adw.WrapBox.props.child_spacing_unit¶
- Name:
child-spacing-unit
- Type:
- Default Value:
- Flags:
The length unit for child spacing.
Allows the spacing to vary depending on the text scale factor.
See [property`WrapBox`:py:data::child-spacing<Adw.WrapBox.props.child_spacing>].
New in version 1.7.
- Adw.WrapBox.props.justify¶
- Name:
justify
- Type:
- Default Value:
- Flags:
Determines whether and how each complete line should be stretched to fill the entire widget.
If set to
ADW_JUSTIFY_FILL
, each widget in the line will be stretched, keeping consistent spacing, so that the line fills the entire widget.If set to
ADW_JUSTIFY_SPREAD
, the spacing between widgets will be increased, keeping widget sizes intact. The first and last widget will be aligned with the beginning and end of the line. If the line only contains a single widget, it will be stretched regardless.If set to
ADW_JUSTIFY_NONE
, the line will not be stretched and the children will be placed together within the line, according to [property`WrapBox`:py:data::align<Adw.WrapBox.props.align>].By default this doesn’t affect the last line, as it will be incomplete. Use [property`WrapBox`:py:data::justify-last-line<Adw.WrapBox.props.justify_last_line>] to justify it as well.
New in version 1.7.
- Adw.WrapBox.props.justify_last_line¶
- Name:
justify-last-line
- Type:
- Default Value:
- Flags:
Whether the last line should be stretched to fill the entire widget.
See [property`WrapBox`:py:data::justify<Adw.WrapBox.props.justify>].
New in version 1.7.
- Adw.WrapBox.props.line_homogeneous¶
- Name:
line-homogeneous
- Type:
- Default Value:
- Flags:
Whether all lines should take the same amount of space.
New in version 1.7.
- Adw.WrapBox.props.line_spacing¶
- Name:
line-spacing
- Type:
- Default Value:
0
- Flags:
The spacing between lines.
See [property`WrapBox`:py:data::line-spacing-unit<Adw.WrapBox.props.line_spacing_unit>].
New in version 1.7.
- Adw.WrapBox.props.line_spacing_unit¶
- Name:
line-spacing-unit
- Type:
- Default Value:
- Flags:
The length unit for line spacing.
Allows the spacing to vary depending on the text scale factor.
See [property`WrapBox`:py:data::line-spacing<Adw.WrapBox.props.line_spacing>].
New in version 1.7.
- Adw.WrapBox.props.natural_line_length¶
- Name:
natural-line-length
- Type:
- Default Value:
-1
- Flags:
Determines the natural size for each line.
It should be used to limit the line lengths, for example when used in popovers.
See [property`WrapBox`:py:data::natural-line-length-unit<Adw.WrapBox.props.natural_line_length_unit>].
New in version 1.7.
- Adw.WrapBox.props.natural_line_length_unit¶
- Name:
natural-line-length-unit
- Type:
- Default Value:
- Flags:
The length unit for natural line length.
Allows the length to vary depending on the text scale factor.
See [property`WrapBox`:py:data::natural-line-length<Adw.WrapBox.props.natural_line_length>].
New in version 1.7.
- Adw.WrapBox.props.pack_direction¶
- Name:
pack-direction
- Type:
- Default Value:
- Flags:
The direction children are packed in each line.
New in version 1.7.
- Adw.WrapBox.props.wrap_policy¶
- Name:
wrap-policy
- Type:
- Default Value:
- Flags:
The policy for line wrapping.
If set to
ADW_WRAP_NATURAL
, the box will wrap to the next line as soon as the previous line cannot fit any more children without shrinking them past their natural size.
If set to
ADW_WRAP_MINIMUM
, the box will try to fit as many children into each line as possible, shrinking them down to their minimum size before wrapping to the next line.New in version 1.7.
- Adw.WrapBox.props.wrap_reverse¶
- Name:
wrap-reverse
- Type:
- Default Value:
- Flags:
Whether wrap direction should be reversed.
By default, lines wrap downwards in a horizontal box, and towards the end in a vertical box. If set to
TRUE
, they wrap upwards or towards the start respectively.New in version 1.7.