|Version 1 (modified by michele, 9 years ago) (diff)|
This page aims to collect opinions regarding TurboGears Widgets.
If you don't know TG widgets take a look at this message from Kevin.
Feel free to add your own opinions and comments to this page.
Actually to use a widget you need to do something like this:
- Create an instance of the widget from your controller
... age_field = widgets.TextField("age", default=0, validator=validators.Int()) ...
- Insert your widget instance inside your template
... <div py:replace="age_field.insert(age)"/> ...
IMHO for the second point we can use Kid py:match attribute to do something like this:
... <widget name="age_field" value="age" /> ...
it shouldn't be to hard if we add to the sitetemplate a definition like this (I have not tested it):
... <span py:match="item.tag == 'widget'" py:replace="getattribute(self, item.get('name'), None).insert(item.get('value'))"> </span> ...
Customizing Widgets Look&Feel
Look&Feel customization is a quite important aspect for widgets. Actually you have two options:
- Providing a custom CSS stylesheet
- Providing a custom Kid template
Customization should be an easy task and should happen inside our templates. Widgets should use CSS class and selector to make it straigthforward.
During the 0.9 IRC Chat all have agreed that widgets should use namespaced class names.
Ability to set common attributes used for widgets
There is a ticket (#106) regarding this. This is an import requirement that will make customization even more easy. Using the syntax I proposed above customization shouldn't be that hard and inside your template you should be able to do the following:
... <widget name="age_field" value="age" size="30" id="id_age_field"/> ...
But, how can we make customization as easy also for complex widgets that embeds others widgets? For example the Form widget? Any opinion?