Clamp

class Clamp(**properties: Any)

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget, Orientable

A widget constraining its child to a given size.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/clamp-wide.png https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/clamp-narrow.png

The AdwClamp widget constrains the size of the widget it contains to a given maximum size. It will constrain the width if it is horizontal, or the height if it is vertical. The expansion of the child from its minimum to its maximum size is eased out for a smooth transition.

If the child requires more than the requested maximum size, it will be allocated the minimum size it can fit in instead.

AdwClamp can scale with the text scale factor, use the unit property to enable that behavior.

CSS nodes

AdwClamp has a single CSS node with name clamp.

Constructors

class Clamp
classmethod new() Widget

Creates a new AdwClamp.

Methods

class Clamp
get_child() Widget | None

Gets the child widget of self.

get_maximum_size() int

Gets the maximum size allocated to the child.

get_tightening_threshold() int

Gets the size above which the child is clamped.

get_unit() LengthUnit

Gets the length unit for maximum size and tightening threshold.

Added in version 1.4.

set_child(child: Widget | None = None) None

Sets the child widget of self.

Parameters:

child – the child widget

set_maximum_size(maximum_size: int) None

Sets the maximum size allocated to the child.

It is the width if the clamp is horizontal, or the height if it is vertical.

Parameters:

maximum_size – the maximum size

set_tightening_threshold(tightening_threshold: int) None

Sets the size above which the child is clamped.

Starting from this size, the clamp will tighten its grip on the child, slowly allocating less and less of the available size up to the maximum allocated size. Below that threshold and below the maximum size, the child will be allocated all the available size.

If the threshold is greater than the maximum size to allocate to the child, the child will be allocated all the size up to the maximum. If the threshold is lower than the minimum size to allocate to the child, that size will be used as the tightening threshold.

Effectively, tightening the grip on the child before it reaches its maximum size makes transitions to and from the maximum size smoother when resizing.

Parameters:

tightening_threshold – the tightening threshold

set_unit(unit: LengthUnit) None

Sets the length unit for maximum size and tightening threshold.

Allows the sizes to vary depending on the text scale factor.

Added in version 1.4.

Parameters:

unit – the length unit

Properties

class Clamp
props.child: Widget

The child widget of the AdwClamp.

props.maximum_size: int

The maximum size allocated to the child.

It is the width if the clamp is horizontal, or the height if it is vertical.

props.tightening_threshold: int

The size above which the child is clamped.

Starting from this size, the clamp will tighten its grip on the child, slowly allocating less and less of the available size up to the maximum allocated size. Below that threshold and below the maximum size, the child will be allocated all the available size.

If the threshold is greater than the maximum size to allocate to the child, the child will be allocated all the size up to the maximum. If the threshold is lower than the minimum size to allocate to the child, that size will be used as the tightening threshold.

Effectively, tightening the grip on the child before it reaches its maximum size makes transitions to and from the maximum size smoother when resizing.

props.unit: LengthUnit

The length unit for maximum size and tightening threshold.

Allows the sizes to vary depending on the text scale factor.

Added in version 1.4.