Hello there! I'm new with Urwid and I'm trying to use it for a littel
project. I've been reading about it and doing simple snippets for 2 weeks.

At the moment I'm just making a proof of concept. I've modified the fib.py
example in order to use SimpleListWalkter with a list, called lalista, and
I'm trying to update the list every second.

When running the attached example, I expect to see the screen been filled
with the 'hola' string every second, but nothing happens.

What am I doing wrong?

Thanks in advance,

-- 
Juanjo Conti
blog: http://www.juanjoconti.com.ar
#!/usr/bin/python

import urwid

lalista = []

def read_file(loop, data):
    lalista.append(urwid.Text('hola'))
    loop.set_alarm_in(1, read_file)

def main():
    palette = [
        ('body','black','dark cyan', 'standout'),
        ('foot','light gray', 'black'),
        ('key','light cyan', 'black', 'underline'),
        ('title', 'white', 'black',),
        ]

    footer_text = [
        ('title', "Fibonacci Set Viewer"), "    ",
        ('key', "UP"), ", ", ('key', "DOWN"), ", ",
        ('key', "PAGE UP"), " and ", ('key', "PAGE DOWN"),
        " move view  ",
        ('key', "Q"), " exits",
        ]

    def exit_on_q(input):
        if input in ('q', 'Q'):
            raise urwid.ExitMainLoop()

    listbox = urwid.ListBox(urwid.SimpleListWalker(lalista))
    footer = urwid.AttrMap(urwid.Text(footer_text), 'foot') #EDIT
    view = urwid.Frame(urwid.AttrWrap(listbox, 'body'), footer=footer)
    loop = urwid.MainLoop(view, palette, unhandled_input=exit_on_q)
    loop.set_alarm_in(1, read_file)
    loop.run()


if __name__=="__main__":
    main()
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to