Closed pylipp closed 7 years ago
Quoting P M (2017-08-06 17:09:58)
Hej everybody, I'm looking for a way to dynamically change a tree (update/delete items), is this currently possible? Reading the urwid docs, I found that such a class has to be derived from MonitoredList but couldn't find anything here. Does anybody have an idea how to start?
I think this is less an issue with urwidtrees rather than urwid widgets itself. You could ask the same question for TextWidgets etc.
This said, my understanding is that MonitoredList will cause the screen to be automatically refreshed once the underlying datastructure changes.
You could do this yourself after changing the data. One way to do this, if I remember correctly, is to call
mainloop.draw_screen()
Another, less brute-force way to do it, would be to emit a "modified" signal from within the widget itself.
Lastly, if you are using urwidtrees, then TreeBox
has a refresh()
method (that unfortunately has no docstrings yet), which would do
the above for you.
So you can use roughtly:
tb = TreeBox(mytree)
# ... stick it into a mainloop and run it ...
mytree.update_in_some_way()
tb.refresh()
I hope this helps, P
Hej everybody, I'm looking for a way to dynamically change a tree (update/delete items), is this currently possible? Reading the urwid docs, I found that such a class has to be derived from
MonitoredList
but couldn't find anything here. Does anybody have an idea how to start?