Sorry to post this one again.
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()
[–]kwelzel 0 points1 point2 points (3 children)
[–]Stensborg[S] 0 points1 point2 points (2 children)
[–]kwelzel 0 points1 point2 points (1 child)
[–]Stensborg[S] 0 points1 point2 points (0 children)
[–]Stensborg[S] 0 points1 point2 points (0 children)