bullet icon indicating copy to clipboard operation
bullet copied to clipboard

feature request: tree view

Open lwerdna opened this issue 5 years ago • 3 comments

Long shot here, but let me dream :)

lwerdna avatar Mar 02 '19 13:03 lwerdna

Can you give a description of the intended functionality you hope to see in a "tree view" feature?

Jengah avatar Mar 06 '19 05:03 Jengah

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.

lwerdna avatar Mar 12 '19 01:03 lwerdna

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")

CurtisPreston99 avatar Mar 12 '19 06:03 CurtisPreston99