AspectFrame
Superclasses: Widget
, InitiallyUnowned
, Object
Implemented Interfaces: Accessible
, Buildable
, ConstraintTarget
GtkAspectFrame
preserves the aspect ratio of its child.
The frame can respect the aspect ratio of the child widget, or use its own aspect ratio.
CSS nodes
GtkAspectFrame
uses a CSS node with name frame
.
Accessibility
Until GTK 4.10, GtkAspectFrame
used the GTK_ACCESSIBLE_ROLE_GROUP
role.
Starting from GTK 4.12, GtkAspectFrame
uses the GTK_ACCESSIBLE_ROLE_GENERIC
role.
Constructors
- class AspectFrame
- classmethod new(xalign: float, yalign: float, ratio: float, obey_child: bool) Widget
Create a new
GtkAspectFrame
.- Parameters:
xalign – Horizontal alignment of the child within the parent. Ranges from 0.0 (left aligned) to 1.0 (right aligned)
yalign – Vertical alignment of the child within the parent. Ranges from 0.0 (top aligned) to 1.0 (bottom aligned)
ratio – The desired aspect ratio.
obey_child – If
True
,ratio
is ignored, and the aspect ratio is taken from the requistion of the child.
Methods
- class AspectFrame
-
- get_obey_child() bool
Returns whether the child’s size request should override the set aspect ratio of the
GtkAspectFrame
.
- get_xalign() float
Returns the horizontal alignment of the child within the allocation of the
GtkAspectFrame
.
- get_yalign() float
Returns the vertical alignment of the child within the allocation of the
GtkAspectFrame
.
- set_child(child: Widget | None = None) None
Sets the child widget of
self
.- Parameters:
child – the child widget
- set_obey_child(obey_child: bool) None
Sets whether the aspect ratio of the child’s size request should override the set aspect ratio of the
GtkAspectFrame
.- Parameters:
obey_child – If
True
,ratio
is ignored, and the aspect ratio is taken from the requisition of the child.
- set_ratio(ratio: float) None
Sets the desired aspect ratio of the child.
- Parameters:
ratio – aspect ratio of the child
Properties
- class AspectFrame
-
- props.ratio: float
The aspect ratio to be used by the
GtkAspectFrame
.This property is only used if
obey_child
is set toFalse
.