Properties

Overview

Properties describe the configuration and state of widgets, and each widget has its own particular set of properties. For example, a widget such as a button or a label has the property label which contains the text of the widget. You can specify the name and value of any number of properties as keyword arguments when creating an instance of a widget: for example, to create a label with the text “Hello World”, an angle of 25 degrees, and aligned to the right, you can use:

label = Gtk.Label(label="Hello World", angle=25, halign=Gtk.Align.END)

which is equivalent to using:

label = Gtk.Label()
label.set_label("Hello World")
label.set_angle(25)
label.set_halign(Gtk.Align.END)

Once you have created such a label, you can get the text of the label with label.get_label(), and analogously for the other properties.

Instead of using getters and setters you can also get and set the properties with get_property("prop-name") and set_property("prop-name", value), respectively.

References

Basics - Properties in Python GTK+ 3 Tutorial