tis 2001-12-18 klockan 03.03 skrev James Henstridge: > To match the __gsignals__ special attribute that gobject.type_register() > recognises, I am now looking at adding support for creating new > properties on python classes. Nice
> > At the moment, the idea is that if a __gproperties__ attribute is found > in the class dictionary, it will be processed for property definitions. > This attribute will be a dict, like __gsignals__. The keys will be > property names, and the values will be tuples of the form: > (type, nick, blurb, [type specific args], flags) > > The appropriate GParamSpec will be created for the requested property > type, and then be added as a property for hte new class. > > At the moment, I am leaving out the property_id tag -- instead the > property name can be looked up as pspec.name. If anyone thinks worrying > about the property ids is worth it, please reply to this message :) > > gobject.type_register will also set a class_init function for the new > type that sets the get_property and set_property virtual functions. The > C functions stuffed into these slots will simply call > "self.do_get_property" or "self.do_set_property" (to match the naming > convention of signals, and because set_property,get_property are already > used). These python functions should have the following form: > def do_get_property(self, pspec): > return something # the value corresponding to the property > pspec.name > def do_set_property(self, pspec, value): > setit(pspec.name, value) Why not just call it __setprop__ and __getprop__ ? > > Possibly making the function arguments more similar to the C > counterparts would be good though. > > Any comments? > > James. > > -- > Email: [EMAIL PROTECTED] > WWW: http://www.daa.com.au/~james/ > > > _______________________________________________ > pygtk mailing list [EMAIL PROTECTED] > http://www.daa.com.au/mailman/listinfo/pygtk _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
