Leaflet#
Deprecated since version 1.4: See the migration guide
Superclasses: Widget, InitiallyUnowned, Object
Implemented Interfaces: Swipeable, Accessible, Buildable, ConstraintTarget, Orientable
An adaptive container acting like a box or a stack.
The AdwLeaflet widget can display its children like a Box does
or like a Stack does, adapting to size changes by switching
between the two modes.
When there is enough space the children are displayed side by side, otherwise only one is displayed and the leaflet is said to be “folded”. The threshold is dictated by the preferred minimum sizes of the children. When a leaflet is folded, the children can be navigated using swipe gestures.
The “over” and “under” transition types stack the children one on top of the other, while the “slide” transition puts the children side by side. While navigating to a child on the side or below can be performed by swiping the current child away, navigating to an upper child requires dragging it from the edge where it resides. This doesn’t affect non-dragging swipes.
CSS nodes#
AdwLeaflet has a single CSS node with name leaflet. The node will get the
style classes .folded when it is folded, .unfolded when it’s not, or none
if it hasn’t computed its fold yet.
Constructors#
- class Leaflet
- classmethod new() Widget#
Creates a new
AdwLeaflet.Deprecated since version 1.4: See the migration guide
Methods#
- class Leaflet
- append(child: Widget) LeafletPage#
Adds a child to
self.Deprecated since version 1.4: See the migration guide
- Parameters:
child – the widget to add
- get_adjacent_child(direction: NavigationDirection) Widget | None#
Finds the previous or next navigatable child.
This will be the same child
navigateor swipe gestures will navigate to.If there’s no child to navigate to,
NULLwill be returned instead.See
navigatable.Deprecated since version 1.4: See the migration guide
- Parameters:
direction – the direction
Gets whether gestures and shortcuts for navigating backward are enabled.
Deprecated since version 1.4: See the migration guide
Gets whether gestures and shortcuts for navigating forward are enabled.
Deprecated since version 1.4: See the migration guide
- get_can_unfold() bool#
Gets whether
selfcan unfold.Deprecated since version 1.4: See the migration guide
- get_child_by_name(name: str) Widget | None#
Finds the child of
selfwithname.Returns
NULLif there is no child with this name.See
name.Deprecated since version 1.4: See the migration guide
- Parameters:
name – the name of the child to find
- get_child_transition_params() SpringParams#
Gets the child transition spring parameters for
self.Deprecated since version 1.4: See the migration guide
- get_child_transition_running() bool#
Gets whether a child transition is currently running for
self.Deprecated since version 1.4: See the migration guide
- get_fold_threshold_policy() FoldThresholdPolicy#
Gets the fold threshold policy for
self.Deprecated since version 1.4: See the migration guide
- get_folded() bool#
Gets whether
selfis folded.The leaflet will be folded if the size allocated to it is smaller than the sum of the minimum or natural sizes of the children (see
fold_threshold_policy), it will be unfolded otherwise.Deprecated since version 1.4: See the migration guide
- get_homogeneous() bool#
Gets whether
selfis homogeneous.Deprecated since version 1.4: See the migration guide
- get_mode_transition_duration() int#
Gets the mode transition animation duration for
self.Deprecated since version 1.4: See the migration guide
- get_page(child: Widget) LeafletPage#
Returns the
LeafletPageobject forchild.Deprecated since version 1.4: See the migration guide
- Parameters:
child – a child of
self
- get_pages() SelectionModel#
Returns a
ListModelthat contains the pages of the leaflet.This can be used to keep an up-to-date view. The model also implements
SelectionModeland can be used to track and change the visible page.Deprecated since version 1.4: See the migration guide
- get_transition_type() LeafletTransitionType#
Gets the type of animation used for transitions between modes and children.
Deprecated since version 1.4: See the migration guide
- get_visible_child() Widget | None#
Gets the widget currently visible when the leaflet is folded.
Deprecated since version 1.4: See the migration guide
- get_visible_child_name() str | None#
Gets the name of the currently visible child widget.
Deprecated since version 1.4: See the migration guide
- insert_child_after(child: Widget, sibling: Widget | None = None) LeafletPage#
Inserts
childin the position aftersiblingin the list of children.If
siblingisNULL, insertschildat the first position.Deprecated since version 1.4: See the migration guide
- Parameters:
child – the widget to insert
sibling – the sibling after which to insert
child
Navigates to the previous or next child.
The child must have the
navigatableproperty set toTRUE, otherwise it will be skipped.This will be the same child as returned by
get_adjacent_childor navigated to via swipe gestures.Deprecated since version 1.4: See the migration guide
- Parameters:
direction – the direction
- prepend(child: Widget) LeafletPage#
Inserts
childat the first position inself.Deprecated since version 1.4: See the migration guide
- Parameters:
child – the widget to prepend
- remove(child: Widget) None#
Removes a child widget from
self.Deprecated since version 1.4: See the migration guide
- Parameters:
child – the child to remove
- reorder_child_after(child: Widget, sibling: Widget | None = None) None#
Moves
childto the position aftersiblingin the list of children.If
siblingisNULL, moveschildto the first position.Deprecated since version 1.4: See the migration guide
- Parameters:
child – the widget to move, must be a child of
selfsibling – the sibling to move
childafter
Sets whether gestures and shortcuts for navigating backward are enabled.
The supported gestures are:
One-finger swipe on touchscreens
Horizontal scrolling on touchpads (usually two-finger swipe)
Back/forward mouse buttons
The keyboard back/forward keys are also supported, as well as the Alt+:kbd:
←shortcut for horizontal orientation, or Alt+:kbd:↑for vertical orientation.If the orientation is horizontal, for right-to-left locales, gestures and shortcuts are reversed.
Only children that have
navigatableset toTRUEcan be navigated to.Deprecated since version 1.4: See the migration guide
- Parameters:
can_navigate_back – the new value
Sets whether gestures and shortcuts for navigating forward are enabled.
The supported gestures are:
One-finger swipe on touchscreens
Horizontal scrolling on touchpads (usually two-finger swipe)
Back/forward mouse buttons
The keyboard back/forward keys are also supported, as well as the Alt+:kbd:
→shortcut for horizontal orientation, or Alt+:kbd:↓for vertical orientation.If the orientation is horizontal, for right-to-left locales, gestures and shortcuts are reversed.
Only children that have
navigatableset toTRUEcan be navigated to.Deprecated since version 1.4: See the migration guide
- Parameters:
can_navigate_forward – the new value
- set_can_unfold(can_unfold: bool) None#
Sets whether
selfcan unfold.Deprecated since version 1.4: See the migration guide
- Parameters:
can_unfold – whether
selfcan unfold
- set_child_transition_params(params: SpringParams) None#
Sets the child transition spring parameters for
self.The default value is equivalent to:
adw_spring_params_new (1, 0.5, 500)
Deprecated since version 1.4: See the migration guide
- Parameters:
params – the new parameters
- set_fold_threshold_policy(policy: FoldThresholdPolicy) None#
Sets the fold threshold policy for
self.If set to
ADW_FOLD_THRESHOLD_POLICY_MINIMUM, it will only fold when the children cannot fit anymore. WithADW_FOLD_THRESHOLD_POLICY_NATURAL, it will fold as soon as children don’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 folding.
Deprecated since version 1.4: See the migration guide
- Parameters:
policy – the policy to use
- set_homogeneous(homogeneous: bool) None#
Sets
selfto be homogeneous or not.If set to
FALSE, different children can have different size along the opposite orientation.Deprecated since version 1.4: See the migration guide
- Parameters:
homogeneous – whether to make
selfhomogeneous
- set_mode_transition_duration(duration: int) None#
Sets the mode transition animation duration for
self.Deprecated since version 1.4: See the migration guide
- Parameters:
duration – the new duration, in milliseconds
- set_transition_type(transition: LeafletTransitionType) None#
Sets the type of animation used for transitions between modes and children.
The transition type can be changed without problems at runtime, so it is possible to change the animation based on the mode or child that is about to become current.
Deprecated since version 1.4: See the migration guide
- Parameters:
transition – the new transition type
- set_visible_child(visible_child: Widget) None#
Sets the widget currently visible when the leaflet is folded.
The transition is determined by
transition_typeandchild_transition_params. The transition can be cancelled by the user, in which case visible child will change back to the previously visible child.Deprecated since version 1.4: See the migration guide
- Parameters:
visible_child – the new child
- set_visible_child_name(name: str) None#
Makes the child with the name
namevisible.See
visible_child.Deprecated since version 1.4: See the migration guide
- Parameters:
name – the name of a child
Properties#
- class Leaflet
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.can_unfold: bool#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.child_transition_params: SpringParams#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.child_transition_running: bool#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.fold_threshold_policy: FoldThresholdPolicy#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.folded: bool#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.homogeneous: bool#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.mode_transition_duration: int#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.pages: SelectionModel#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.transition_type: LeafletTransitionType#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.visible_child: Widget#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide
- props.visible_child_name: str#
The type of the None singleton.
Deprecated since version 1.4: See the migration guide