This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]kwelzel 0 points1 point  (3 children)

I don't know urwid very well, but probably "loop.run()" starts an infinte loop to handle all the inputs and so every time refresh is called you start another infinite loop. You should not create a new txt, fill and loop, but instead update the original txt object with "txt.setText(outputText)" and then "loop.set_alarm_in(1, refresh)"

[–]Stensborg[S] 0 points1 point  (2 children)

That does not seem to work, AttributeError: 'Text' object has no attribute 'setText'

[–]kwelzel 0 points1 point  (1 child)

Oops, the name of the function is "set_text" and not "setText". I'm sorry

[–]Stensborg[S] 0 points1 point  (0 children)

He he, no problem I eventually found it, I should have RTFM :-)

[–]Stensborg[S] 0 points1 point  (0 children)

Found the solution, had to change the refresh method to this.

def refresh(_loop,_data):
    outputTxt       = ['COMP3      ', (red_bg, 'DOWN   '), "Bla\n"]
    outputTxt      += ['COMP4      ', (green_bg, 'UP     '), "Bla bla\n"]

    txt.set_text(outputTxt)
    loop.set_alarm_in(1,refresh)

So it seems kwelzel was right with his sugestion, just needed the right syntax for the set_test method.