On Monday 11 June 2007 17:06, remi jolin wrote:
> Hello,
>
> I was trying to define a CompoundWidget with TGwidgets and could not get
> it working because I was defining all the attributes within the __init__
> method.
>
> After reading the widgets.base.py source I discovered that
> member_widgets was to be defined at the "class level" and not in the
> __init__ method because it is then used as
> self.__class__.member_widgets. Why not simply self.member_widgets ???
>
> Actually, my goal was to define a widget where some fields would be
> defined at instanciation time depending on a parameter passed at its
> creation...

The reason for all this fancy class-stuff is that then metaclass-magic can 
make things work a bit more declarative.

Take the WidgetsList for example. Without class-level declaration, one 
wouldn't get the left-side name:

class MyWidgets(WidgetsList):
      foo = Whatever()

Usually you can make things work somehow in update_params or the constructor - 
but I don't know how in your case as I didn't work with CompoundWidgets so 
far.

But at least you now know why things are the way they are ... :)

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to