Gtk.Frame

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.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Frame Gtk.Frame Gtk.Widget->Gtk.Frame

Example

../_images/Frame.png
Subclasses:

None

Methods

Inherited:

Gtk.Widget (183), GObject.Object (37), Gtk.Accessible (17), Gtk.Buildable (1)

Structs:

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

class

new (label)

get_child ()

get_label ()

get_label_align ()

get_label_widget ()

set_child (child)

set_label (label)

set_label_align (xalign)

set_label_widget (label_widget)

Virtual Methods

Inherited:

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

do_compute_child_allocation (allocation)

Properties

Inherited:

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

Name

Type

Flags

Short Description

child

Gtk.Widget

r/w/en

label

str

r/w/en

label-widget

Gtk.Widget

r/w/en

label-xalign

float

r/w/en

Signals

Inherited:

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

Fields

Inherited:

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

Name

Type

Access

Description

parent_instance

Gtk.Widget

r

Class Details

class Gtk.Frame(**kwargs)
Bases:

Gtk.Widget

Abstract:

No

Structure:

Gtk.FrameClass

Surrounds its child with a decorative frame and an optional label.

<picture> <source srcset=”frame-dark.png” media=”(prefers-color-scheme: dark)”> <img alt=”An example Gtk.Frame" src=”frame.png”> </picture>

If present, the label is drawn inside the top edge of the frame. The horizontal position of the label can be controlled with [method`Gtk`.Frame.set_label_align].

GtkFrame clips its child. You can use this to add rounded corners to widgets, but be aware that it also cuts off shadows.

Gtk.Frame as Gtk.Buildable

An example of a UI definition fragment with Gtk.Frame:

``xml <object class=”GtkFrame”>

<property name=”label-widget”>

<object class=”GtkLabel” id=”frame_label”/>

</property> <property name=”child”>

<object class=”GtkEntry” id=”frame_content”/>

</property>

</object> ``

CSS nodes

`` frame ├── <label widget> ╰── <child> ``

GtkFrame has a main CSS node with name “frame”, which is used to draw the visible border. You can set the appearance of the border using CSS properties like “border-style” on this node.

Accessibility

GtkFrame uses the [enum`Gtk`.AccessibleRole.group] role.

classmethod new(label)[source]
Parameters:

label (str or None) – the text to use as the label of the frame

Returns:

a new GtkFrame widget

Return type:

Gtk.Widget

Creates a new GtkFrame, with optional label label.

If label is None, the label is omitted.

get_child()[source]
Returns:

the child widget of self

Return type:

Gtk.Widget or None

Gets the child widget of self.

get_label()[source]
Returns:

the text in the label, or None if there was no label widget or the label widget was not a GtkLabel. This string is owned by GTK and must not be modified or freed.

Return type:

str or None

Returns the frame labels text.

If the frame’s label widget is not a GtkLabel, None is returned.

get_label_align()[source]
Returns:

the frames X alignment

Return type:

float

Retrieves the X alignment of the frame’s label.

get_label_widget()[source]
Returns:

the label widget

Return type:

Gtk.Widget or None

Retrieves the label widget for the frame.

set_child(child)[source]
Parameters:

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

Sets the child widget of self.

set_label(label)[source]
Parameters:

label (str or None) – the text to use as the label of the frame

Creates a new GtkLabel with the label and sets it as the frame’s label widget.

set_label_align(xalign)[source]
Parameters:

xalign (float) – The position of the label along the top edge of the widget. A value of 0.0 represents left alignment; 1.0 represents right alignment.

Sets the X alignment of the frame widget’s label.

The default value for a newly created frame is 0.0.

set_label_widget(label_widget)[source]
Parameters:

label_widget (Gtk.Widget or None) – the new label widget

Sets the label widget for the frame.

This is the widget that will appear embedded in the top edge of the frame as a title.

do_compute_child_allocation(allocation) virtual
Parameters:

allocation (Gdk.Rectangle) –

Property Details

Gtk.Frame.props.child
Name:

child

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The child widget.

Gtk.Frame.props.label
Name:

label

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Text of the frame’s label.

Gtk.Frame.props.label_widget
Name:

label-widget

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Widget to display in place of the usual frame label.

Gtk.Frame.props.label_xalign
Name:

label-xalign

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The horizontal alignment of the label.