FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 5.16 | Next Entry >>

5.16. What's the difference between a property and an attribute?

In the Pygtk reference documentation there are a section for properties and another one for attributes for most of the widgets.

A property is a GObject property and can be read and write with the GObject.get_property (propname) and GObject.set_property (propname, value) methods.

An attribute is a mapping to the C struct of the GObject and can be read from and (sometimes) written to directly. For example:

 adj = gtk.Adjustment(value=0, lower=0, upper=100, step_incr=1, page_incr=10, page_size=10)
 adj.value = 4.0
Since PyGTK 2.8, GObject properties are now mapped as attributes of a special 'props' attribute (gnome bug #81879), so the following also works:
 adj.props.value = 4.0

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org