bullet
bullet copied to clipboard
feature request: tree view
Long shot here, but let me dream :)
Can you give a description of the intended functionality you hope to see in a "tree view" feature?
Sure, I want a list where there is a hierarchy, and by expanding one given list item, its sub options become available.
In a filesystem analogy, the un-expanded list items are folders, and the sub options becoming available when you click to expand are the files within that folder.
you can already do something like the file thing
from bullet import Bullet
from bullet import colors
import os
d = '.'
while True:
files=[os.path.join(d, o) for o in os.listdir(d)
if os.path.isdir(os.path.join(d,o))]
cli = Bullet(
prompt = "\nPlease choose a fruit: ",
choices =files,
indent = 0,
align = 5,
margin = 2,
shift = 0,
bullet = "",
pad_right = 5
)
result = cli.launch()
print("You chose:", result)
os.chdir(result)
but in my fork Bullet supports dicts that you could feed the "tree structure" into like this
from bullet import Bullet
from bullet import colors
tree ={"op1":{"subop1":"end"},
"op2":{"subop2":"end"},
"op3":{"subop3":
{"subsub op":"end"}}}
while True:
cli = Bullet(
prompt = "\nPlease choose a fruit: ",
choices =tree,
indent = 0,
align = 5,
margin = 2,
shift = 0,
bullet = "",
pad_right = 5
)
result = cli.launch()
print("You chose:", result)
tree=result
if(tree=="end"):
break
print("reached leaf")