GNOME Bugzilla – Bug 325453
support for Python properties
Last modified: 2006-01-02 04:15:43 UTC
Currently the way to access the properties of pygtk objects is to either use the get_property()/set_property() methods or the appropriate accessor methods. It would be nice if pygtk could support Python properties as introduced in Python 2.2. This way a more "natural" access of properties is possible. For example with gtk.SpinButton, properties could be implemented like this: class SpinButton(gtk.Entry): ... # Since SpinButton does not expose get_climb_rate() and set_climb_rate() methods, # define them as private: def __get_climb_rate(self): return self.adjustment.climb_rate def __set_climb_rate(self, climb_rate): self.adjustment.climb_rate = climb_rate ... # Properties adjustment = property(get_adjustment, set_adjustment, None, "Docstring ...") climb_rate = property(__get_climb_rate, __set_climb_rate, None, "Docstring ...") digits = property(get_digits, set_digits, None, "Docstring ...") ... Long term, get_property()/set_property() as well as the getter/setter methods could be deprecated.
Properties are exposed via self.props in fairly recent pygtk releases *** This bug has been marked as a duplicate of 81879 ***