[Urwid] How do you use SimpleListWalker?
Ian Ward
ian at excess.org
Sat Jun 20 10:30:08 EDT 2009
Corrected example below.
Ian Ward wrote:
> What you describe should work, but I'm not a fan of mixing such
> different interfaces in the same class.
>
> I would use a slightly modified SimpleListWalker class for storing your
> list of conversations, and give each of your conversation objects a
> button object (or whatever widget you like) stored as ".widget"
class ThreadedMessageWalker(SimpleListWalker):
def get_focus(self):
if len(self)==0: return None, None
return self[self.focus].widget, self.focus
def get_next(self, start_from):
pos = start_from+1
if len(self) <= pos: return None, None
return self[pos].widget, pos
def get_prev(self, start_from):
pos = start_from-1
if pos < 0: return None, None
return self[pos].widget, pos
>
> This way your list updates automatically, and the ListBox only sees the
> widgets.
>
> Ian
More information about the Urwid
mailing list