This is just class inheritance. ThreadedMessageWalker is a ListWalker you can use to store your conversation objects. If you pass it to a ListBox, the ListBox will display the .widget members of your conversation objects, instead of trying to use the conversation objects themselves as a widgets.
Ian Dominic LoBue wrote: > A class within a class? How would I share the data from the parent > class with the child class? > > Dominic > > On Jun 20, 2009, at 7:30, Ian Ward <[email protected]> wrote: > >> 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 >> >> _______________________________________________ >> Urwid mailing list >> [email protected] >> http://lists.excess.org/mailman/listinfo/urwid >> > > > _______________________________________________ > Urwid mailing list > [email protected] > http://lists.excess.org/mailman/listinfo/urwid > _______________________________________________ Urwid mailing list [email protected] http://lists.excess.org/mailman/listinfo/urwid
