Rudi
2018-03-05 10:32:24 UTC
I am trying output some test to the screen, but I have to update the text
when some external data changes.
So I made this test program, and even though it works, I think I am doing
something very wrong, since it seems like I am creating loops within loops.
Can someone tell me what i am doing wrong?
#!/usr/bin/python
import urwid
def unhandled_input(key):
if key == 'q':
raise urwid.ExitMainLoop()
def refresh(_loop,_data):
outputTxt = ['COMP3 ', (red_bg, 'DOWN '), "Bla\n"]
outputTxt += ['COMP4 ', (green_bg, 'UP '), "Bla bla\n"]
txt = urwid.Text(outputTxt)
fill = urwid.Filler(txt, 'top')
loop = urwid.MainLoop(fill, unhandled_input=unhandled_input)
loop.set_alarm_in(1,refresh)
loop.run()
red_bg = urwid.AttrSpec('default', 'dark red')
green_bg = urwid.AttrSpec('default', 'dark green')
outputTxt = ['COMP1 ', (red_bg, 'DOWN '), "Bla\n"]
outputTxt += ['COMP2 ', (green_bg, 'UP '), "Bla bla\n"]
txt = urwid.Text(outputTxt)
fill = urwid.Filler(txt, 'top')
loop = urwid.MainLoop(fill, unhandled_input=unhandled_input)
loop.set_alarm_in(1,refresh)
loop.run()
when some external data changes.
So I made this test program, and even though it works, I think I am doing
something very wrong, since it seems like I am creating loops within loops.
Can someone tell me what i am doing wrong?
#!/usr/bin/python
import urwid
def unhandled_input(key):
if key == 'q':
raise urwid.ExitMainLoop()
def refresh(_loop,_data):
outputTxt = ['COMP3 ', (red_bg, 'DOWN '), "Bla\n"]
outputTxt += ['COMP4 ', (green_bg, 'UP '), "Bla bla\n"]
txt = urwid.Text(outputTxt)
fill = urwid.Filler(txt, 'top')
loop = urwid.MainLoop(fill, unhandled_input=unhandled_input)
loop.set_alarm_in(1,refresh)
loop.run()
red_bg = urwid.AttrSpec('default', 'dark red')
green_bg = urwid.AttrSpec('default', 'dark green')
outputTxt = ['COMP1 ', (red_bg, 'DOWN '), "Bla\n"]
outputTxt += ['COMP2 ', (green_bg, 'UP '), "Bla bla\n"]
txt = urwid.Text(outputTxt)
fill = urwid.Filler(txt, 'top')
loop = urwid.MainLoop(fill, unhandled_input=unhandled_input)
loop.set_alarm_in(1,refresh)
loop.run()
--
You received this message because you are subscribed to the Google Groups "Urwid Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to urwid+***@excess.org.
To post to this group, send email to ***@excess.org.
For more options, visit https://groups.google.com/a/excess.org/d/optout.
You received this message because you are subscribed to the Google Groups "Urwid Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to urwid+***@excess.org.
To post to this group, send email to ***@excess.org.
For more options, visit https://groups.google.com/a/excess.org/d/optout.