PyGTK properties versus python properties -
when deriving gobject class in pygtk, can define gobject properties in c, using __gproperties__ dict, , do_get_property/do_set_property methods, described here in sub-classing gobject in python. note written before had @property decorator in python.
gobject properties have advantage can connect object's notify::property-name signal receive notification whenever property changes. other that, there reason use gobject properties instead of python's @property decorator?
why not use them? simplified version provided python bindings, defining gobject properties not different defining python properties.
having said that, there couple of advantages other notification. 1 i've made use of in past property setting in gtk.builder files. example, in ui file,
<object class="gtkimage" id="image"> <property name="stock">gtk-missing-image</property> </object> sets stock property on image object when constructed builder class; if use gobject properties in custom widgets, can take advantage of too. behaviour more useful advent of property binding support in glade.
another potential advantage gobject properties' min/max limits , default values integers , floats, can useful ui-related properties.
Comments
Post a Comment