[Urwid] question : how to display python list using listbox

bino oetomo bino at indoakses-online.com
Fri Sep 9 22:20:35 EDT 2011


Dear All
c/q Ian and Alain

I really appreciate your enlightment

On 09/09/2011 09:57 PM, Ian Ward wrote:
> Nice answer Alain.  I'd like to suggest a small change:
> I would replace this:
>
>>       def __init__(self, ids, txts):
>>           super(BottomWalker, self).__init__(zip(ids, txts))
>>       getvalues = SimpleListWalker.__getitem__
>>       def __getitem__(self, focus):
>>           return AttrWrap(SelectableText('%s %s' % self.getvalues(focus)), None, 'focus')
>>       def set_focus(self, focus):
>>           emit_signal(self, 'focus changed', self.getvalues(focus))
>>           return super(BottomWalker, self).set_focus(focus)
> With this:
>
>       def __init__(self, ids, txts):
>           super(BottomWalker, self).__init__([])
>           for v in zip(ids, txts):
>               w = AttrWrap(SelectableText('%s %s' % v), None, 'focus')
>               w._values = v
>               self.append(w)
>       def set_focus(self, focus):
>           emit_signal(self, 'focus changed', self[focus]._values)
>           return super(BottomWalker, self).set_focus(focus)
>
>
> When you recreate widgets every time the list content is requested Urwid
> will redraw those widgets every time.  By keeping them around the
> caching will work properly.
>
> If you have a case where keeping widget objects around is too much of a
> burden on memory, or if you want to lazily create widgets but still want
> the caching to work, it should be possible to store weak references to
> the widgets.  As long as a widget is on screen Urwid's cache will keep a
> reference to it.
>

With my lame brain ... today I found that "zip" is combining the two 
list into tuple.
Ian , I read that you write urwid as part of your POS project back in 2000.
I'm trying to write a POS for OpenERP ... so the data will fetch/feed 
using XML RPC rather than using SQL.

I don't know where it will end.

Sincerely
-bino-



More information about the Urwid mailing list