The widget itself displays fine and sadly enough I use dictionaries
all over the place with widgets in them. Just the CSS does not get
included for some reason. My original example was terrible I'm sorry.
So let's say I extend a TextField like this:
class MyTextField(TextField):
css = [CSSLink("tester.widgets.css", "mytextfield.css")]
And then use a form like this:
form = TableForm(name="form", fields=[MyTextField()], submit_text="Save")
Now here is the problem(two cases of returning to a template):
controller
widget, widgetData = {}, {}
widget['form'] = form
widgetData['form'] = {}
return dict(widget=widget, widgetData=widgetData)
template
${widget['form'](**widgetData['form'])}
out
<HEAD><META CONTENT="text/html; charset=utf-8" HTTP-EQUIV="Content-Type">
<STYLE TYPE="text/css">
#pageLogin
{
font-size: 10px;
font-family: verdana;
text-align: right;
}
</STYLE>
</HEAD>
---------------------VERSUS----------------------
controller
widget = form
widgetData = {}
return dict(widget=widget, widgetData=widgetData)
template
${widget(**widgetData)}
out
<HEAD><META CONTENT="text/html; charset=utf-8" HTTP-EQUIV="Content-Type">
<LINK MEDIA="all"
HREF="/tg_widgets/tester.widgets.css/mytextfield.css" TYPE="text/css"
REL="stylesheet">
<STYLE TYPE="text/css">
#pageLogin
{
font-size: 10px;
font-family: verdana;
text-align: right;
}
</STYLE>
</HEAD>
In both cases the actual widget displays fine, but in only one does
the css get included in the html block HEAD.
Thanks.
-Ian
On 9/15/06, Jorge Godoy <[EMAIL PROTECTED]> wrote:
>
> "Ian Wilson" <[EMAIL PROTECTED]> writes:
>
> > Do I really have to pass all the widgets as explict members of the return
> > dict?
>
> Hmmm... No, you don't.
>
> In [1]:from turbogears import widgets
>
> In [2]:a = [widgets.TextField(name='widget_a'),
> widgets.CheckBox(name='widget_b')]
>
> In [3]:a
> Out[3]:
> [TextField(name='widget_a', convert=True, field_class='textfield', attrs={},
> css_classes=[]),
> CheckBox(name='widget_b', convert=True, field_class='checkbox', attrs={},
> css_classes=[])]
>
> In [4]:a[0].render()
> Out[4]:'<INPUT ID="widget_a" TYPE="text" CLASS="textfield" NAME="widget_a">'
>
> In [5]:a[1].render()
> Out[5]:'<INPUT CLASS="checkbox" TYPE="checkbox" ID="widget_b"
> NAME="widget_b">'
>
>
> As you can see, they can be wrapped on a list. Lets try a dict:
>
> In [6]:d = dict(widget_a = a[0], widget_b=a[1])
>
> In [7]:d['widget_a'].render()
> Out[7]:'<INPUT ID="widget_a" TYPE="text" CLASS="textfield" NAME="widget_a">'
>
> In [8]:d['widget_b'].render()
> Out[8]:'<INPUT CLASS="checkbox" TYPE="checkbox" ID="widget_b"
> NAME="widget_b">'
>
>
> So they can also be in a dictionary.
>
>
> Does it help?
>
> --
> Jorge Godoy <[EMAIL PROTECTED]>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---