PyInquirer
PyInquirer copied to clipboard
Using a seperate list for choices?
Say I have a list that's user created, or I'm storing options for restoring save points in my program, I need keys that can be displayed.
Something like:
list = [Key1, Key2 ,Key3 ,Key4 ,Key5]
questions = [
{
'type': 'list',
'name': 'saves',
'message': "What save would you like to load?",
'choices': list
}
]
@Sentr1k I finally found how to do it here is the question/answer
questions = [
{
'type': 'list',
'name': 'file',
'message': 'Select file to open',
'choices': list_files(projects_path),
}
]
answers = prompt(questions, style=custom_style_2)
and here is my function with parameter
def list_files(projects_path):
files = []
for file in listdir(str(projects_path)):
files.append(file)
return files
Here is the result:
@CITGuru you can close this issue now