[Urwid] nested frames -> footer contents change problem

Rybarczyk Tomasz paluho at gmail.com
Mon Jun 23 08:48:42 EDT 2008


Hi,

It's me again...  Previous simple example is working well in newer
urwid version but there is a little bit more complicated one which
fails for me (with 0.9.8.2 ;-)). I want to change content of inner
Frame footer while browsing listbox but instead this uwrid overwrites
outer Frame footer. Additionally from some point (if you scroll list
down) it's changing inner footer as it should. Is it again my fault?


import urwid.raw_display
import urwid
import sys


class TextField(urwid.WidgetWrap):
    def __init__(self, text):
        self.widget = urwid.Text(text)
        self.w = urwid.AttrWrap(self.widget,'body','focus')
        urwid.WidgetWrap.__init__(self, self.w)
        self.selected = False

    def keypress(self, size, key):
        return key

    def selectable(self):
        return True



def run():
    some_text_list = urwid.SimpleListWalker(map(TextField, (("this is
some content of list"*10).split())))
    listbox = urwid.ListBox(some_text_list)

    inner_foot = urwid.Text("inner_foot")
    inner_head = urwid.Text("inner_head")

    inner_frame = urwid.Frame(body=listbox, footer=inner_foot,
header=inner_head)

    outer_foot = urwid.Text("outer_foot")
    outer_head = urwid.Text("outer_head")
    outer_frame = urwid.Frame(body=inner_frame, footer=outer_foot,
header=outer_head)

    size = ui.get_cols_rows()
    canvas = outer_frame.render(size, focus=1)
    ui.draw_screen(size, canvas)

    while True:
        size = ui.get_cols_rows()
        key = ui.get_input()
        for k in key:
            if k == 'j' or k=='down':
                outer_frame.keypress(size, 'down')
                inner_foot.set_text(listbox.get_focus()[0].widget.text)
            elif k == 'k' or k=='up':
                outer_frame.keypress(size, 'up')
                inner_foot.set_text(listbox.get_focus()[0].widget.text)

        canvas = outer_frame.render(size, focus=1)
        ui.draw_screen(size, canvas)


palette = [
    ('body', 'black', 'light gray'),
    ('focus', 'dark gray', 'dark blue', 'standout')]

ui = urwid.raw_display.Screen()
ui.register_palette(palette)
ui.run_wrapper(run)


Thanks in advance
paluh

On Mon, Jun 23, 2008 at 12:28 PM, Rybarczyk Tomasz <paluho at gmail.com> wrote:
> Hi Ian,
>
> Sorry - my fault - I'v been using 0.9.8.1... In 0.9.8.2 everything is ok.
>
> Thanks
> paluh
>
> On Sun, Jun 22, 2008 at 8:10 PM, Ian Ward <ian at excess.org> wrote:
>> Rybarczyk Tomasz wrote:
>>> Sorry I've commented wrong line in this code sample. should be
>>> commented out in opposite way ;-) to achive described problem. I mean:
>>>
>>> On Sun, Jun 22, 2008 at 6:37 PM, Rybarczyk Tomasz <paluho at gmail.com> wrote:
>>>> Hi,
>>>>
>>>> I'm trying to write some interface (similar to vifm) in which I need
>>>> to have some contents (for example listbox) and two footers which can
>>>> easily change contents. I thing that the simplest way is to just
>>>> create two nested urwid.Frames. Everything seems ok but when I'm
>>>> trying to change contents of footer of inner Frame it prints the
>>>> contents on footer of outer frame....
>>>> Example code should explain what I mean. What am I doing wrong?
>>
>> I can't seem to reproduce your problem with Urwid 0.9.8.2 or 0.9.7.2,
>> what version are you running?
>>
>> Ian
>>
>>
>> _______________________________________________
>> Urwid mailing list
>> Urwid at lists.excess.org
>> http://lists.excess.org/mailman/listinfo/urwid
>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple.py
Type: text/x-python
Size: 1723 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20080623/1ce5f151/attachment-0001.py 


More information about the Urwid mailing list