[Urwid] How do you use SimpleListWalker?
Dominic LoBue
dom.lobue at gmail.com
Sat Jun 20 16:21:35 EDT 2009
Sorry, I meant the .widget attribute in the convContainer.
Correct me if I am wrong, but methods are the only way to work with
shared data in an instance implicitly, right? While I suppose that I
could make a method that returns the widget with the data needed, that
could create a new copy of the data set every time it was used,
wouldn't it?
Dominic
On Sat, Jun 20, 2009 at 11:54 AM, Ian Ward<ian at excess.org> wrote:
> 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 <ian at excess.org> 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
>>> Urwid at lists.excess.org
>>> http://lists.excess.org/mailman/listinfo/urwid
>>>
>>
>>
>> _______________________________________________
>> Urwid mailing list
>> Urwid at lists.excess.org
>> http://lists.excess.org/mailman/listinfo/urwid
>>
>
>
>
> _______________________________________________
> Urwid mailing list
> Urwid at lists.excess.org
> http://lists.excess.org/mailman/listinfo/urwid
>
>
More information about the Urwid
mailing list