The 'class CheckBoxListDesc(CoreWD)' is only relevent to the toolbox. If you are creating you own widgets to be packaged
as an add-on to TG, then it's used to show how your widget is to be used. Basically, it doesn't need to be in your
controller at all. I am using the svn version of TG and I don't recall what version  you are using.
In any case I think you also need a form too. This provides the submit mechanism. I am attaching a very crude example of
what you can use as a base.

In controllers.py  my additions are in bold:

 from turbogears import controllers, expose, validate, redirect, flash
 from turbogears.widgets import CheckBoxList, TableForm

 from cb import json

 log = logging.getLogger("cb.controllers")

for_widget = CheckBoxList("your_checkbox_list",
                              options=[(1, "Python"),
                                       (2, "Java"),
                                       (3, "Pascal"),
                                       (4, "Ruby")],
                              default=[1,4])
S
ome_form = TableForm(

    name='form', submit_text = 'Update',
    fields = [for_widget])


  class Root(controllers.RootController):
     @expose(template="cb.templates.welcome")
     def index(self , **kw):
          import time
          log.debug("Happy TurboGears Controller Responding For Duty")
          if kw:
               flash('FLASH: '+ str(kw))
         return dict(now=time.ctime(), form=Some_form)

In welcome.kid I added ${form.display()}
When you use the submit button, the FLASH message appears at the top of the page.
I hope this little example helps.

Nicky

On 7/31/06, OriginalBrownster <[EMAIL PROTECTED] > wrote:

Hi

I want to know how to implement the following source code and template
sample they gave within the widget browser.


I reviewed over the checkbox widget, and I think it will be easier
using the widget than creating my own form in my template.

I am assuming this is supposed to go in the controller


class CheckBoxListDesc(CoreWD):
    name = "CheckBox List"
    for_widget = CheckBoxList("your_checkbox_list",
                              options=[(1, "Python"),
                                       (2, "Java"),
                                       (3, "Pascal"),
                                       (4, "Ruby")],
                              default=[1,4])

and this in the template
<ul xmlns:py=" http://purl.org/kid/ns#"
        class="${field_class}"
        id="${field_id}"
        py:attrs="list_attrs"
    >
        <li py:for="" desc, attrs in options">
            <input type="checkbox"
                name="${name}"
                id="${field_id}_${value}"
                value="${value}"
                py:attrs="attrs"
            />
            <label for="" py:content="desc" />
        </li>
    </ul>


However I get a traceback error

Traceback (most recent call last):
  File "/var/projects/document_site/se/start-se.py", line 27, in ?
    from se.controllers import Root
  File "/var/projects/document_site/se/se/controllers.py", line 75, in
?
    class CheckBoxListDesc(CoreWD):
NameError: name 'CoreWD' is not defined



I need alot of help with this. I've been trying to use checkboxs within
my application but I have had NO SUCCESS. If someone is willing to help
me out it would be greatly appreciated.

Thank you
Stephen





--
--
Nicky Ayoub
G-Mail Account
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Attachment: cb.tar.gz
Description: GNU Zip compressed data

Reply via email to