Properties describe the configuration and state of widgets. Each
widget has its own particular set of properties. For example, a widget such as
a button 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)
Alternatively, you can define these properties separately by using the method associated with it.
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.
Basics - Properties in Python GTK+ 3 Tutorial