I'm sure many people have been wondering over the years why we have to do this: label.set_property("text", "hello")
instead of this: label.text = "hello" Clearly the current way of getting and setting GObject properties is suboptimal. The PyGTK developers would like to fix this situation in PyGTK 2.8. However, the situation is not as simple as it looks. The straightforward mapping "obj.propname = value" cannot be used because it risks API breakage when upgrading to a new gtk+ library. For example, let's see this example: class MyLabel(gtk.Label): def __init__(self): gtk.Label.__init__(sel) self.clickable = True # .... Ok, so this code would currently work fine. Now suppose we are using pygtk 2.8 with the straight mapping I described above. The program probably works fine in gtk 2.8. But now suppose the user upgrades to gtk 2.10, which incidentally adds a new property to gtk.Label called 'clickable' of type gtk.Widget. Suddenly the program stops working, since __init__ is trying to assign True to a GObject property of type widget. We have currently two alternative solutions in mind, to workaround this issue: 1. Map GObject property names to python attributes with a predefined prefix reserved for properties. Examples: label.prop_text, label.proptext, etc.. (others?) 2. Create a properties container object. Examples label.prop.text, label.props.text, label.properties.text, (others?) In any case, applications know which namespace is forbidden for them to use for their own attributes, and that prevents unexpected future breakage. So, let's hear some opinions from PyGTK users. Starting with myself ;-) I have a slight preference for label.prop.text. Regards. -- Gustavo J. A. M. Carneiro <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> The universe is always one step beyond logic.
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/