Gtk.AspectFrame

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.AspectFrame Gtk.AspectFrame Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Widget->Gtk.AspectFrame

Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new (xalign, yalign, ratio, obey_child)

get_child ()

get_obey_child ()

get_ratio ()

get_xalign ()

get_yalign ()

set_child (child)

set_obey_child (obey_child)

set_ratio (ratio)

set_xalign (xalign)

set_yalign (yalign)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1)

Name

Type

Flags

Short Description

child

Gtk.Widget

r/w/en

obey-child

bool

r/w/en

ratio

float

r/w/en

xalign

float

r/w/en

yalign

float

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class Gtk.AspectFrame(**kwargs)
Bases:

Gtk.Widget

Abstract:

No

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.

classmethod new(xalign, yalign, ratio, obey_child)[source]
Parameters:
  • xalign (float) – Horizontal alignment of the child within the parent. Ranges from 0.0 (left aligned) to 1.0 (right aligned)

  • yalign (float) – Vertical alignment of the child within the parent. Ranges from 0.0 (top aligned) to 1.0 (bottom aligned)

  • ratio (float) – The desired aspect ratio.

  • obey_child (bool) – If True, ratio is ignored, and the aspect ratio is taken from the requistion of the child.

Returns:

the new GtkAspectFrame.

Return type:

Gtk.Widget

Create a new GtkAspectFrame.

get_child()[source]
Returns:

the child widget of self

Return type:

Gtk.Widget or None

Gets the child widget of self.

get_obey_child()[source]
Returns:

whether to obey the child’s size request

Return type:

bool

Returns whether the child’s size request should override the set aspect ratio of the GtkAspectFrame.

get_ratio()[source]
Returns:

the desired aspect ratio

Return type:

float

Returns the desired aspect ratio of the child.

get_xalign()[source]
Returns:

the horizontal alignment

Return type:

float

Returns the horizontal alignment of the child within the allocation of the GtkAspectFrame.

get_yalign()[source]
Returns:

the vertical alignment

Return type:

float

Returns the vertical alignment of the child within the allocation of the GtkAspectFrame.

set_child(child)[source]
Parameters:

child (Gtk.Widget or None) – the child widget

Sets the child widget of self.

set_obey_child(obey_child)[source]
Parameters:

obey_child (bool) – If True, ratio is ignored, and the aspect ratio is taken from the requisition of the child.

Sets whether the aspect ratio of the child’s size request should override the set aspect ratio of the GtkAspectFrame.

set_ratio(ratio)[source]
Parameters:

ratio (float) – aspect ratio of the child

Sets the desired aspect ratio of the child.

set_xalign(xalign)[source]
Parameters:

xalign (float) – horizontal alignment, from 0.0 (left aligned) to 1.0 (right aligned)

Sets the horizontal alignment of the child within the allocation of the GtkAspectFrame.

set_yalign(yalign)[source]
Parameters:

yalign (float) – horizontal alignment, from 0.0 (top aligned) to 1.0 (bottom aligned)

Sets the vertical alignment of the child within the allocation of the GtkAspectFrame.

Property Details

Gtk.AspectFrame.props.child
Name:

child

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The child widget.

Gtk.AspectFrame.props.obey_child
Name:

obey-child

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the GtkAspectFrame should use the aspect ratio of its child.

Gtk.AspectFrame.props.ratio
Name:

ratio

Type:

float

Default Value:

1.0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The aspect ratio to be used by the GtkAspectFrame.

This property is only used if [property`Gtk`.AspectFrame:obey-child] is set to False.

Gtk.AspectFrame.props.xalign
Name:

xalign

Type:

float

Default Value:

0.5

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The horizontal alignment of the child.

Gtk.AspectFrame.props.yalign
Name:

yalign

Type:

float

Default Value:

0.5

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The vertical alignment of the child.