ToscaWidget Widget

4 views
Skip to first unread message

cd34

unread,
Nov 1, 2009, 12:27:30 AM11/1/09
to ToscaWidgets-discuss
I need to display a line of text within a form. I'm using help_text
for that currently, but, it would render much more nicely if I had a
Widget that put a label and the text as if it was a form field.

I looked through the documentation, but, didn't see anything like
that. I am using WidgetsList which doesn't allow the 'blank' spacing
line to be entered.

Is there a method to do this or should I write two widgets to handle
this?

Diez B. Roggisch

unread,
Nov 2, 2009, 4:53:38 PM11/2/09
to toscawidge...@googlegroups.com
cd34 schrieb:

I guess it depends on your desired HTML. If you subclass a Widget from
tw.forms.FormField, then it should be rendered as part of the form.


Diez

Paul Johnston

unread,
Nov 3, 2009, 5:19:52 AM11/3/09
to toscawidge...@googlegroups.com
Hi

> I need to display a line of text within a form.  I'm using help_text
> for that currently, but, it would render much more nicely if I had a
> Widget that put a label and the text as if it was a form field.

You want a Label field. I notice this isn't in the docs, but it works just fine.

Paul

cd34

unread,
Nov 3, 2009, 2:39:04 PM11/3/09
to ToscaWidgets-discuss
label = Label(text='text to display')

works, and places the text in the table row and sets colspan=2

spacer = Spacer() actually puts Spacer in the label which can be
adjusted with:

spacer = Spacer(label_text='')

I believe in fields.py,

suppress_label = True

should probably be set in class Spacer.

However, Label is close to what I need, but, since it doesn't allow me
to put a label on one side and my message on the other, I need to
modify the widget I was working on. The behavior I was trying to
emulate is closer to:

label = Label(label_text='Label to display', text='display text in
second column')

I was able to do that with:

class Line(FormField):
"""
A label field with text
"""
params = ['text']
text = ''
template = "tw.forms.templates.label"
validator = None
suppress_label = False

However, if the documentation is autogenerated from the source, how
did these classes get omitted? Thank you for the pointer to them.

Paul Johnston

unread,
Nov 3, 2009, 7:22:01 PM11/3/09
to toscawidge...@googlegroups.com
Hi,

> label = Label(text='text to display')
> works, and places the text in the table row and sets colspan=2

Cool

> I believe in fields.py,
> suppress_label = True
> should probably be set in class Spacer.

Yes, I think you're right. I don't really touch tw 0.9 these days, but
someone will probably apply this.

> label = Label(label_text='Label to display', text='display text in
> second column')

You can use:
label = Label(suppress_label=False, label_text='Label to display',


text='display text in second column')

And your solution works just fine too.

> However, if the documentation is autogenerated from the source, how
> did these classes get omitted?  Thank you for the pointer to them.

It's not fully autogenerated, the sphinx source has a line for each
widget that's included. It would be a simple change to add these
widgets.

Paul

Diez B. Roggisch

unread,
Nov 4, 2009, 6:24:42 AM11/4/09
to toscawidge...@googlegroups.com
> > However, if the documentation is autogenerated from the source, how
> > did these classes get omitted?  Thank you for the pointer to them.
>
> It's not fully autogenerated, the sphinx source has a line for each
> widget that's included. It would be a simple change to add these
> widgets.

Might be - but as nobody cared to update the docs for the last release anyway,
it's a kind of a moot point. And actually a reason for me not to care to much
about 0.9 as well.

Diez

Paul Johnston

unread,
Nov 4, 2009, 10:19:34 AM11/4/09
to toscawidge...@googlegroups.com
Hi,

> Might be - but as nobody cared to update the docs for the last release anyway,
> it's a kind of a moot point. And actually a reason for me not to care to much
> about 0.9 as well.

Do you mean the docs were updated in the repository, but no-one
updated the website? If so, I should be able to hop on and do it, just
let me know.

Paul

Diez B. Roggisch

unread,
Nov 4, 2009, 11:11:02 AM11/4/09
to toscawidge...@googlegroups.com

Yep, that's what I mean. I asked for it weeks ago (also for a tw.dynforms
release, as that was forgotten), but Chris (or anybody else, but he was the
one pushing out the release) didn't react. Nor did I get access to the
machine myself, as it was planned several months ago.

Add the lack of any credits given to me for being responsible (in good and
bad) for most of the work on 0.9.8, and you have one fed up developer who now
maintains his own fork.

I work on bugfixes that result from my work at the 0.9.8 release, as I stand
by my code. But that's pretty much it.

Diez

Paul Johnston

unread,
Nov 4, 2009, 11:32:53 AM11/4/09
to toscawidge...@googlegroups.com
Hi,

> Yep, that's what I mean. I asked for it weeks ago

Ok, I've just updated ToscaWidgets and tw.forms. I'll hold on
tw.dynforms, pending release.

> (also for a tw.dynforms
> release, as that was forgotten)

Happy in principle to do this. I don't want to rush doing a release,
it's a bugger when that gets messed up. Should be able to do it over
the weekend though.

> Nor did I get access to the
> machine myself, as it was planned several months ago.

Lets take this one to private mail.

> Add the lack of any credits given to me for being responsible (in good and
> bad) for most of the work on 0.9.8, and you have one fed up developer who now
> maintains his own fork.

I think you got some great features in. It's a shame you feel fed up,
but, well, I understand where you're coming from. I'm actually
terrified of modifying tw0.9 code, it seems way too easy to break
things.

Take care bud,

Paul

Reply all
Reply to author
Forward
0 new messages