Patch: add html_attrs keyword arg to widget classes
Greg Ward
2003-11-30
OK, the "Generalizing frame/widget framework a bit" thread had lots of
good things to say. I'm attaching a patch in two parts that, IMHO,
represents the group consensus. This is relative to Quixote 0.7a2; my
previous patch in this direction is withdrawn.
Part 1 adds a new instance attribute 'html_attrs' to Widget. There's a
corresponding keyword argument to the constructor of all Widget classes,
which expects a dictionary. This dictionary gets (almost) no special
treatment; if you want to use Python keywords like 'class' as HTML
attribute names, no problem:
TextWidget(..., html_attrs={'class': "mystyle"})
The render() method of each Widget class is responsible for including
html_attrs in the rendered output. Most Widget classes only output a
single tag, so it's pretty obvious where the specified attributes go.
Some (namely the SelectWidget-derived classes) have multiple tags;
html_attrs generally affects the top-level, outermost tag, eg.