Olli Wang wrote:
> hi, I really want to use pictures in RadioButtonList options.
>
> I tried:
> options=[(123, "<img src='/static/images/test.gif'/>")]
>
> but only got html code in page, could anyone tell me how to show the
> picture? thanks.
Does something like this work?
class MyRadioButtonList(RadioButtonList):
template = """
<ul xmlns:py="http://purl.org/kid/ns#"
class="${field_class}"
id="${field_id}"
>
<li py:for="value, desc, attrs in options">
<input type="radio"
name="${name}"
id="${field_id}_${value}"
value="${value}"
py:attrs="attrs"
/>
<img scr="${desc}" />
</li>
</ul>
"""
the you use MyRadioButtonList instead of RadioButtonList and pass
options in this way:
options=[(123, "/static/images/test.gif")]
Not tested but I think it should work.
Remember that you can easily customize some portion of the widget
behavior and everything of his appaerance just by customizing its
template.
You can also do the above thing by putting the template into a variable
and using:
RadioButtonList(template=my_template_variable, options=[(123, "<img
src='/static/images/test.gif'/>")])
Hope it works.
Ciao
Michele
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---