[Urwid] urwid.Pile() - ValueError: too many values to unpack

Ian Ward ian at excess.org
Tue Apr 18 14:15:21 EDT 2006


Bernardo Torres wrote:
> Hi,
> 
> I'm starting to use Urwid and I have a little doubt about this program I made:
...
>   mods = []
>   for mod in modules:
>     mods.append(urwid.AttrWrap(urwid.Text(mod["name"]), 'header'))
>   mods = urwid.ListBox(mods)
>   title = urwid.Text(('header', "Diag"))
>   footer = urwid.Text(('header', "Aperte F8 para sair"))
>   body = mods
>   box = urwid.Pile([title, body, footer])

This last line is the problem.  ListBox widgets are box widgets, but 
Pile widgets may only contain flow widgets.

You could replace the line above with:
     box = urwid.Frame( body, header=title, footer=footer )

Frame widgets have one box widget in the middle and may have header and 
footer flow widgets on the top and bottom.

...
> What I wanted to do is something like what's in the attachment.
> 
> Any idea would be nice.
> Thanks,

In your diagram you are also showing two columns.  To create columns you 
use the Columns widget.  Something like this would work:

left_list = [urwid.Text("blablab\nOther text\n\nAnother txt")]
left_col = urwid.ListBox( left_list )
right_list = [urwid.Text("Some widgets here:"),urwid.Edit("Edits","")]
right_col = urwid.ListBox( right_list )
body = urwid.Columns([ ('weight',1,left_col), ('weight',3,right_col) ])

This creates two seperate ListBox widgets, one using 1/4 of the 
available space and the other using 3/4.

Hope this helps!

Ian




More information about the Urwid mailing list