On Sun, Jul 25, 2004 at 02:52:24AM -0500, Doug Quale wrote:
> The real reason I chose dictionary syntax over attribute syntax is
> that I use the widget names as attributes for another purpose. The
> Python 2.2+ data descriptor facility allows using descriptors to
> provide attribute syntax to get and set widget values.
>
> class widget(object):
[snip]
This is interesting, though I question the design of that
if-looks-like-a-switch-with-a-load-of-isinstances <wink>.
Kiwi Proxies do this by creating individualized "descriptors" -- each
widget gets its own WidgetProxy which has read() and update() methods,
and there are WidgetProxies for every widget type [for which a
descriptor would make sense]. This is used internally by the Kiwi Proxy,
but could be made generally available (and even transparently available,
as your descriptor class really is).
> To use this, you put something like this in your class:
>
> class MyController(GWidget):
>
> name = widget('name') # name entry
> age = widget('age') # age spinbutton
So in this case you could hack around them a bit and have
class MyController(GWidget):
name = LabelProxy('name')
age = SpinButtonProxy('name')
Maybe the StudlyCaps isn't what you're looking for (and that's the
easiest part to change), but this solution tends to scale nicely (and
you can add extra stuff to specific proxies, such as automatic format
and type conversion).
Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 2331
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/