I am starting to use urwid and one of the simple things I want to do is have two columns and being able to update one of the columns to display a different widget
I tried the following code but I keep getting an error
urwid.container.ColumnsError: added content invalid <Filler box widget <Text flow widget 'other test'>>
I just want to be able to replace
from urwid import *
cols = Columns([Filler(Text('test')), Filler(Text('test'))])
loop = MainLoop(cols)
cols.contents[0] = Filler(Text('other test'))
# also tried .append just for trying, same result
loop.run()
I am aware I could change the Text widget with ".set_text()" but that is not what I am trying to do I want to replace it with other widget.
I am starting to think this is clearly not the way it should be done but can't find anything about this.
thanks in advance.
You're pretty close! :)
When updating the contents
list, you need to provide a tuple that contains both the widget and an options object (which you can construct with the options()
method), like:
cols.contents[0] = (Filler(Text('other test')), cols.options())