On 1/16/06, Mike Kent <[EMAIL PROTECTED]> wrote:
> Well, I spent the weekend  learning to write widgets.  Thanks to Karl
> for pointing me to the Fieldset widget as a good container example.

No prob, I spent a weekend doing the same thing not too long ago.


> Here's a small example, formatted for clarity:
You actually don't need the backslashes in python if you have an open
parenthesis or bracket:

mytable = Table(
  header = TableHeader(
    rows = [foobar]),
  bar = baz
)

Is perfectly legal python.



> A TableCell can contain any number of other widgets of any widget type.
>  Hopefully, if I've gotten all this right, these widgets give us the
> ability to do any kind of table layout that we can do in straight HTML.

You may want to check to make sure that js and css in the contained
wigets gets propagated up through your class. It's an edge case and I
know that FieldSet didn't handle this properly at one point...

>  We could even create a Form widget, put these table widgets inside the
> Form widget, put various Label and Field-type widgets in the table
> cells, and have the equivalent of a TableForm widget, but with better
> flexibility.
But at the cost of convenience. Right now, you just toss your widgets
in and TableForm handles them for you, which is nice.

> It may be a mistake to limit our scope.  We
> might want to take a look at refactoring the current Widget base class
> to move the form-input code out to a new 'FormWidget' class that would
> be the base class of form-oriented classes.

The reason widgets aren't output oriented is because the intent was to
leave output formatting to the templating library. That's why widgets
have a source method. The idea is that when you need more flexibility,
you override the widget's template.

Or at least that was the plan, I just tried it and can't figure out
how it is supposed to work. ;]

Reply via email to