You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a hierarchy of data that I'd like to visualize using Tree(). It should look something like:
a
|--b
|--c
|--d
However, based on the dox, it seems that the only ways to accomplish this is with either:
tree.add().add().add()
recursively calling add() on the Tree object
The first option doesn't lend itself to scripting, as I can't build a command dynamically with a bunch of add() calls if I don't know how deep my data hierarchy will be.
For a bunch of code style mandate reasons, recursion is not an option in my code base. I was hoping to be able to do someting like:
listdata = [str(i) for i in (range(1, 10)]
tree = Tree('my tree')
fill_tree.add(listdata[0])
for i in listdata[1:]:
fill_tree = fill_tree.add(i)
But this doesn't work as expected, as everything hangs off the first branch, instead of being properly nested.
Is there some way to accomplish what I need, or is this a limitation of how Tree() works inside of rich?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've got a hierarchy of data that I'd like to visualize using Tree(). It should look something like:
However, based on the dox, it seems that the only ways to accomplish this is with either:
The first option doesn't lend itself to scripting, as I can't build a command dynamically with a bunch of add() calls if I don't know how deep my data hierarchy will be.
For a bunch of code style mandate reasons, recursion is not an option in my code base. I was hoping to be able to do someting like:
But this doesn't work as expected, as everything hangs off the first branch, instead of being properly nested.
Is there some way to accomplish what I need, or is this a limitation of how Tree() works inside of rich?
Beta Was this translation helpful? Give feedback.
All reactions