Squeezer
Deprecated since version 1.4: See the migration guide
Superclasses: Widget
, InitiallyUnowned
, Object
Implemented Interfaces: Accessible
, Buildable
, ConstraintTarget
, Orientable
A best fit container.
The AdwSqueezer
widget is a container which only shows the first of its
children that fits in the available size. It is convenient to offer different
widgets to represent the same data with different levels of detail, making
the widget seem to squeeze itself to fit in the available space.
Transitions between children can be animated as fades. This can be controlled
with transition_type
.
CSS nodes
AdwSqueezer
has a single CSS node with name squeezer
.
Constructors
Methods
- class Squeezer
- add(child: Widget) SqueezerPage
Adds a child to
self
.Deprecated since version 1.4:
- Parameters:
child – the widget to add
- get_allow_none() bool
Gets whether to allow squeezing beyond the last child’s minimum size.
Deprecated since version 1.4:
- get_homogeneous() bool
Gets whether all children have the same size for the opposite orientation.
Deprecated since version 1.4:
- get_interpolate_size() bool
Gets whether
self
interpolates its size when changing the visible child.Deprecated since version 1.4:
- get_page(child: Widget) SqueezerPage
Returns the
SqueezerPage
object forchild
.Deprecated since version 1.4:
- Parameters:
child – a child of
self
- get_pages() SelectionModel
Returns a
ListModel
that contains the pages ofself
.This can be used to keep an up-to-date view. The model also implements
SelectionModel
and can be used to track the visible page.Deprecated since version 1.4:
- get_switch_threshold_policy() FoldThresholdPolicy
Gets the switch threshold policy for
self
.Deprecated since version 1.4:
- get_transition_duration() int
Gets the transition animation duration for
self
.Deprecated since version 1.4:
- get_transition_running() bool
Gets whether a transition is currently running for
self
.If a transition is impossible, the property value will be set to
TRUE
and then immediately toFALSE
, so it’s possible to rely on its notifications to know that a transition has happened.Deprecated since version 1.4:
- get_transition_type() SqueezerTransitionType
Gets the type of animation used for transitions between children in
self
.Deprecated since version 1.4:
- get_visible_child() Widget | None
Gets the currently visible child of
self
.Deprecated since version 1.4:
- get_xalign() float
Gets the horizontal alignment, from 0 (start) to 1 (end).
Deprecated since version 1.4:
- get_yalign() float
Gets the vertical alignment, from 0 (top) to 1 (bottom).
Deprecated since version 1.4:
- remove(child: Widget) None
Removes a child widget from
self
.Deprecated since version 1.4:
- Parameters:
child – the child to remove
- set_allow_none(allow_none: bool) None
Sets whether to allow squeezing beyond the last child’s minimum size.
If set to
TRUE
, the squeezer can shrink to the point where no child can be shown. This is functionally equivalent to appending a widget with 0×0 minimum size.Deprecated since version 1.4:
- Parameters:
allow_none – whether
self
allows squeezing beyond the last child
- set_homogeneous(homogeneous: bool) None
Sets whether all children have the same size for the opposite orientation.
For example, if a squeezer is horizontal and is homogeneous, it will request the same height for all its children. If it isn’t, the squeezer may change size when a different child becomes visible.
Deprecated since version 1.4:
- Parameters:
homogeneous – whether
self
is homogeneous
- set_interpolate_size(interpolate_size: bool) None
Sets whether
self
interpolates its size when changing the visible child.If
TRUE
, the squeezer will interpolate its size between the one of the previous visible child and the one of the new visible child, according to the set transition duration and the orientation, e.g. if the squeezer is horizontal, it will interpolate the its height.Deprecated since version 1.4:
- Parameters:
interpolate_size – whether to interpolate the size
- set_switch_threshold_policy(policy: FoldThresholdPolicy) None
Sets the switch threshold policy for
self
.Determines when the squeezer will switch children.
If set to
ADW_FOLD_THRESHOLD_POLICY_MINIMUM
, it will only switch when the visible child cannot fit anymore. WithADW_FOLD_THRESHOLD_POLICY_NATURAL
, it will switch as soon as the visible child doesn’t get their natural size.This can be useful if you have a long ellipsizing label and want to let it ellipsize instead of immediately switching.
Deprecated since version 1.4:
- Parameters:
policy – the policy to use
- set_transition_duration(duration: int) None
Sets the transition animation duration for
self
.Deprecated since version 1.4:
- Parameters:
duration – the new duration, in milliseconds
- set_transition_type(transition: SqueezerTransitionType) None
Sets the type of animation used for transitions between children in
self
.Deprecated since version 1.4:
- Parameters:
transition – the new transition type
- set_xalign(xalign: float) None
Sets the horizontal alignment, from 0 (start) to 1 (end).
This affects the children allocation during transitions, when they exceed the size of the squeezer.
For example, 0.5 means the child will be centered, 0 means it will keep the start side aligned and overflow the end side, and 1 means the opposite.
Deprecated since version 1.4:
- Parameters:
xalign – the new alignment value
- set_yalign(yalign: float) None
Sets the vertical alignment, from 0 (top) to 1 (bottom).
This affects the children allocation during transitions, when they exceed the size of the squeezer.
For example, 0.5 means the child will be centered, 0 means it will keep the top side aligned and overflow the bottom side, and 1 means the opposite.
Deprecated since version 1.4:
- Parameters:
yalign – the new alignment value
Properties
- class Squeezer
- props.allow_none: bool
Whether to allow squeezing beyond the last child’s minimum size.
If set to
TRUE
, the squeezer can shrink to the point where no child can be shown. This is functionally equivalent to appending a widget with 0×0 minimum size.Deprecated since version 1.4:
- props.homogeneous: bool
Whether all children have the same size for the opposite orientation.
For example, if a squeezer is horizontal and is homogeneous, it will request the same height for all its children. If it isn’t, the squeezer may change size when a different child becomes visible.
Deprecated since version 1.4:
- props.interpolate_size: bool
Whether the squeezer interpolates its size when changing the visible child.
If
TRUE
, the squeezer will interpolate its size between the one of the previous visible child and the one of the new visible child, according to the set transition duration and the orientation, e.g. if the squeezer is horizontal, it will interpolate the its height.Deprecated since version 1.4:
- props.pages: SelectionModel
A selection model with the squeezer’s pages.
This can be used to keep an up-to-date view. The model also implements
SelectionModel
and can be used to track the visible page.Deprecated since version 1.4:
- props.switch_threshold_policy: FoldThresholdPolicy
The switch threshold policy.
Determines when the squeezer will switch children.
If set to
ADW_FOLD_THRESHOLD_POLICY_MINIMUM
, it will only switch when the visible child cannot fit anymore. WithADW_FOLD_THRESHOLD_POLICY_NATURAL
, it will switch as soon as the visible child doesn’t get their natural size.This can be useful if you have a long ellipsizing label and want to let it ellipsize instead of immediately switching.
Deprecated since version 1.4:
- props.transition_duration: int
The transition animation duration, in milliseconds.
Deprecated since version 1.4:
- props.transition_running: bool
Whether a transition is currently running.
If a transition is impossible, the property value will be set to
TRUE
and then immediately toFALSE
, so it’s possible to rely on its notifications to know that a transition has happened.Deprecated since version 1.4:
- props.transition_type: SqueezerTransitionType
The type of animation used for transitions between children.
Deprecated since version 1.4:
- props.xalign: float
The horizontal alignment, from 0 (start) to 1 (end).
This affects the children allocation during transitions, when they exceed the size of the squeezer.
For example, 0.5 means the child will be centered, 0 means it will keep the start side aligned and overflow the end side, and 1 means the opposite.
Deprecated since version 1.4:
- props.yalign: float
The vertical alignment, from 0 (top) to 1 (bottom).
This affects the children allocation during transitions, when they exceed the size of the squeezer.
For example, 0.5 means the child will be centered, 0 means it will keep the top side aligned and overflow the bottom side, and 1 means the opposite.
Deprecated since version 1.4: