:right-sidebar: True AspectFrame =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: AspectFrame(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.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 ``aspectframe``\. 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 ------------ .. rst-class:: interim-class .. class:: AspectFrame :no-index: .. classmethod:: new(xalign: float, yalign: float, ratio: float, obey_child: bool) -> ~gi.repository.Gtk.Widget Create a new ``GtkAspectFrame``\. :param xalign: Horizontal alignment of the child within the parent. Ranges from 0.0 (left aligned) to 1.0 (right aligned) :param yalign: Vertical alignment of the child within the parent. Ranges from 0.0 (top aligned) to 1.0 (bottom aligned) :param ratio: The desired aspect ratio. :param obey_child: If :const:`True`, ``ratio`` is ignored, and the aspect ratio is taken from the requistion of the child. Methods ------- .. rst-class:: interim-class .. class:: AspectFrame :no-index: .. method:: get_child() -> ~gi.repository.Gtk.Widget | None Gets the child widget of ``self``\. .. method:: get_obey_child() -> bool Returns whether the child's size request should override the set aspect ratio of the ``GtkAspectFrame``\. .. method:: get_ratio() -> float Returns the desired aspect ratio of the child. .. method:: get_xalign() -> float Returns the horizontal alignment of the child within the allocation of the ``GtkAspectFrame``\. .. method:: get_yalign() -> float Returns the vertical alignment of the child within the allocation of the ``GtkAspectFrame``\. .. method:: set_child(child: ~gi.repository.Gtk.Widget | None = None) -> None Sets the child widget of ``self``\. :param child: the child widget .. method:: 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``\. :param obey_child: If :const:`True`, ``ratio`` is ignored, and the aspect ratio is taken from the requisition of the child. .. method:: set_ratio(ratio: float) -> None Sets the desired aspect ratio of the child. :param ratio: aspect ratio of the child .. method:: set_xalign(xalign: float) -> None Sets the horizontal alignment of the child within the allocation of the ``GtkAspectFrame``\. :param xalign: horizontal alignment, from 0.0 (left aligned) to 1.0 (right aligned) .. method:: set_yalign(yalign: float) -> None Sets the vertical alignment of the child within the allocation of the ``GtkAspectFrame``\. :param yalign: horizontal alignment, from 0.0 (top aligned) to 1.0 (bottom aligned) Properties ---------- .. rst-class:: interim-class .. class:: AspectFrame :no-index: .. attribute:: props.child :type: ~gi.repository.Gtk.Widget The type of the None singleton. .. attribute:: props.obey_child :type: bool The type of the None singleton. .. attribute:: props.ratio :type: float The type of the None singleton. .. attribute:: props.xalign :type: float The type of the None singleton. .. attribute:: props.yalign :type: float The type of the None singleton.