[Urwid] Completely changing listbox contents
dominic.lobue at gmail.com
Wed Jul 21 01:26:42 EDT 2010
On Tue, Jul 20, 2010 at 1:03 PM, Mariusz Kruk
<Mariusz.Kruk at epsilon.eu.org> wrote:
> On Tue, Jul 20, 2010 at 08:20:18PM +0500, Muhammad Ammar wrote:
>> check the browse.py example at following link
>> and source code here
> Thanks for hint but I think I wasn't specific enough with my questions.
> The problem is that I want to keep the design "as objective" as possible
> meaning I want to delegate as few things outside my objects as possible.
> So the natural solution would be to wrap every directory/file object
> into a directory or file widget and run apropriate methods from those
> widgets. But this leaves me with no way to "cleanly" operate on the
> listbox contents unless I'm missing something.
> Another approach (which I think you might be suggesting) would be to do
> something similar to fib.py example - create widgets on the fly when
> apropriate methods in listwalker are called. Its not a bad idea in
> itself but it gives me an impression of unnecessary complexity and the
> idea of creating and destroying unnecessarily all the time feels a
> little ugly.
> So I'm looking for another ways of solving this problem.
> I know that I always can make a function outside of the
> list/listwalker/widgets code that would just update the list contents
> and call this function when apropriate keys are pressed but that's not
> what I'm looking for.
> I hope I made myself a bit more clear this time. :-)
> Urwid mailing list
> Urwid at lists.excess.org
I ran into a similar problem while working on my urwid-based email
client. I wanted to create something like gmail, where you can
collapse an entire email to a single summary line, but you could also
collapse only quoted replies, and each quoted reply could be collapsed
or expanded separately.
In order to do this I needed all the widgets that make up a single
email message to be nested under the parent message object. Needless
to say, since you can't combine multiple list walkers in a single
listbox, this was a bit difficult.
My solution was to create special collapser list objects with variable
length depending on the attributes expanded, detailed, and label. For
example if expanded was set to false, then it would report a length of
1 and only show the label widget.
You can see how I did it here:
More information about the Urwid