[Urwid] Screens with forms with fixed-length input fields.

Christopher R. Hertel crh at ubiqx.mn.org
Sun Jun 5 14:59:11 EDT 2011

Christopher R. Hertel <crh <at> ubiqx.mn.org> writes:

One more note about this code snippet:

>     prompt  = u.Text( "Gimme Input:", align='right' )
>     prompt  = u.AttrMap( prompt, 'normal', 'focusprompt' )
>     #
>     f_widget = u.AttrMap( TextEdit( "", fwidth ), 'normal', 'focusfield' )
>     f_widget = u.Padding( f_widget, width=fwidth+1, right=2 )
>     f_widget = [ prompt, ('weight', 2, f_widget) ]
>     f_widget = u.Columns( f_widget, dividechars=1 )
>     f_widget = u.AttrMap( f_widget, None, {'normal':'focusprompt'} )
>     self._widgets.append( f_widget )

Note that I set attributes on the prompt twice: in the second line, and in the
penultimate line.

The first time, I set them on the Text object.  The second time, I set them on
the Columns object.  That works, but if I comment out *either* line the prompt
fails to change attributes when the column row is in focus.

I just don't understand why that is the case.

I also don't understand why I don't need to set the normal/focusfield
attributes on the Columns object.  Those attributes work fine.

Chris -)-----

More information about the Urwid mailing list