Gtk.AspectFrame

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.AspectFrame Gtk.AspectFrame Gtk.Bin Gtk.Bin Gtk.Frame Gtk.Frame Gtk.Bin->Gtk.Frame Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Frame->Gtk.AspectFrame Gtk.Widget->Gtk.Container

Subclasses:None

Methods

Inherited:Gtk.Frame (9), Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)
Structs:Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
class new (label, xalign, yalign, ratio, obey_child)
  set (xalign, yalign, ratio, obey_child)

Properties

Inherited:Gtk.Frame (5), Gtk.Container (3), Gtk.Widget (39)
Name Type Flags Short Description
obey-child bool r/w/en Force aspect ratio to match that of the frame’s child
ratio float r/w/en Aspect ratio if obey_child is False
xalign float r/w/en X alignment of the child
yalign float r/w/en Y alignment of the child

Style Properties

Inherited:Gtk.Widget (17)

Fields

Inherited:Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)
Name Type Access Description
frame Gtk.Frame r  

Class Details

class Gtk.AspectFrame(**kwargs)
Bases:Gtk.Frame
Abstract:No
Structure:Gtk.AspectFrameClass

The Gtk.AspectFrame is useful when you want pack a widget so that it can resize but always retains the same aspect ratio. For instance, one might be drawing a small preview of a larger image. Gtk.AspectFrame derives from Gtk.Frame, so it can draw a label and a frame around the child. The frame will be “shrink-wrapped” to the size of the child.

CSS nodes

Gtk.AspectFrame uses a CSS node with name frame.

classmethod new(label, xalign, yalign, ratio, obey_child)[source]
Parameters:
  • label (str or None) – Label text.
  • xalign (float) – Horizontal alignment of the child within the allocation of the Gtk.AspectFrame. This ranges from 0.0 (left aligned) to 1.0 (right aligned)
  • yalign (float) – Vertical alignment of the child within the allocation of the Gtk.AspectFrame. This 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 Gtk.AspectFrame.

Return type:

Gtk.Widget

Create a new Gtk.AspectFrame.

set(xalign, yalign, ratio, obey_child)[source]
Parameters:
  • xalign (float) – Horizontal alignment of the child within the allocation of the Gtk.AspectFrame. This ranges from 0.0 (left aligned) to 1.0 (right aligned)
  • yalign (float) – Vertical alignment of the child within the allocation of the Gtk.AspectFrame. This 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.

Set parameters for an existing Gtk.AspectFrame.

Property Details

Gtk.AspectFrame.props.obey_child
Name:obey-child
Type:bool
Default Value:True
Flags:READABLE, WRITABLE, EXPLICIT_NOTIFY

Force aspect ratio to match that of the frame’s child

Gtk.AspectFrame.props.ratio
Name:ratio
Type:float
Default Value:1.0
Flags:READABLE, WRITABLE, EXPLICIT_NOTIFY

Aspect ratio if obey_child is False

Gtk.AspectFrame.props.xalign
Name:xalign
Type:float
Default Value:0.5
Flags:READABLE, WRITABLE, EXPLICIT_NOTIFY

X alignment of the child

Gtk.AspectFrame.props.yalign
Name:yalign
Type:float
Default Value:0.5
Flags:READABLE, WRITABLE, EXPLICIT_NOTIFY

Y alignment of the child