[Urwid] Create pile from list

Fabian Braennstroem f.braennstroem at gmx.de
Tue Jun 2 01:02:21 EDT 2009

Hi Ian,
Ian Ward wrote:
> Fabian Braennstroem wrote:
>> Hi,
>> I would like to create a pile from a list of e.g. 'Text' widgets.
>> Right now, I am doing something like this:
>> self.piler=Pile([Button(liste[0]) ,Text(liste[1]) 
>> ,Text(liste[2]),Text(liste[3]) ,Edit(liste[4]) ,Text(liste[5]) 
>> ,Text(liste[6]) ,Text(liste[7]) ,Text(liste[8])])
>> but in general I have no idea about the length of the list, so a loop 
>> over every list item would be needed. Does anyone have an idea?
> Are you just asking how to make a Text widget for every item in a list? 
>   Pile([Text(x) for x in liste])
Ah, quite simple... this probably works for every widget as long as 
there is no mixing between different widgets.

>> And one more question, I am often using a simple 'print' to 'debug' 
>> certain variables, but this does not work in background!? Thanks!
> The best way of handling debugging at the moment is to use the python 
> logging module to log to a file.  printing will disturb urwid's output.
> There is some interesting work going on in this area, however. 
> Hopefully Andrew will have some code to post soon.

Thanks for the help!

More information about the Urwid mailing list