Frame

A Frame is a container widget used to group other widgets which perform related functions.

Constructor

The Frame can be constructed using the following:

frame = Gtk.Frame(label)

The label parameter should be set to a string of text which is displayed on the Frame to indicate what the group of child widgets relates to.

Methods

To set the label text on the frame after constructing use:

frame.set_label(label)

Alternatively, a Label widget can be used on the Frame if required by calling:

frame.set_label_widget(label_widget)

By default, the label is positioned in the top-left corner of the Frame. This can be changed using:

frame.set_label_align(xalign, yalign)

The xalign and yalign values should be float values between 0.0 and 1.0. By default, these values are set to 0.0 and 0.5 on a newly created Frame.

Example

Below is an example of a Frame:

#!/usr/bin/env python3

from gi.repository import Gtk

class Frame(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_default_size(200, 200)
        self.set_border_width(5)
        self.connect("destroy", Gtk.main_quit)

        frame = Gtk.Frame(label="Frame")
        self.add(frame)

        label = Gtk.Label("Label in a Frame")
        frame.add(label)

window = Frame()
window.show_all()

Gtk.main()

Download: Frame