On Sun, Jul 25, 2004 at 01:53:08PM +0530, Sridhar R wrote:
> >     def __set__(self, obj, value):
> >         widget = obj[self.widget_name]
> > 
> >         if isinstance(widget, gtk.Label):
> >             widget.set_label(str(value))
> >         elif isinstance(widget, gtk.SpinButton):
> >             widget.set_value(value)
> >         elif isinstance(widget, gtk.Entry):
> >             widget.set_text(str(value))
> >         elif isinstance(widget, gtk.Combo):
> >             widget.get_entry().set_text(value)
> >         elif isinstance(widget, gtk.ToggleButton):
> >             widget.set_active(value)
> >             widget.set_inconsistent(value is None)
> >         elif isinstance(widget, gtk.TextView):
> >             buffer = widget.get_buffer()
> >             buffer.set_text(value)
> >         else:
> >             raise ValueError, 'Unrecognized widget type %r' % (type(widget),)
> 
> Introspection can be used to remove those if..else part.

Sure, you could also have a dictionary and look up an appropriate
function to handle that widget. Maybe Doug is concerned that calling a
function every time you want to get or set a value is going to be
expensive?

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/

Reply via email to