[Urwid] Pile failing to render all items after widget_list.append()

Ian Ward ian at excess.org
Fri Jul 2 19:54:16 EDT 2010

Jacob wrote on 2010-07-02 16:58:
> Hi,
> I've come across an odd problem while subclassing Pile.
> The widget list [which is the MonitoredList created by Pile::__init__] holds the 
> correct content when appended to, but nothing new is rendered.
> In the example below, I would expect all three Text widgets to be displayed, but 
> only the 'Me first!' widget appears.
> Looking through Pile::render and doing a bit of debugging, it appears that the 
> problem is on line 819 of container.py in the Pile class:
> "for (f, height), w in  zip(self.item_types, self.widget_list):"
> item_types is only one, and zip truncates the results to one tuple.
> I had assumed that appending to the MonitoredList widget_list would 
> automatically take care of these sorts of things.
> My question is, what is the best way to get around this?

A workaround for now is to insert (or append) similarly to item_types,
but I agree, that's not how it should be.  MonitoredList is invalidating
the widget when you change the list so it may be redrawn, but a fancier
MonitoredList that can keep the item_list in sync would be better.  Once
that is done there's still a problem of choosing a default item_type for
new items that appear in the list.

At one point someone on the list or in IRC suggested adding another
widget decoration that would communicate to the Pile/ListBox how the
contained widget should be displayed.  That might be a good solution for
adding new items.

I was hoping to fix this and a similar problem in Columns by refactoring
all the container widgets to remove the common layout and list
management code, while making the interfaces consistent at the same
time.  Haven't gotten to that yet, as I admit at the bottom of


More information about the Urwid mailing list