select.py 516 B

123456789101112131415161718192021
  1. from PyInquirer import prompt
  2. # Select an item from a list
  3. class Selecter:
  4. def __init__(self, choices, question = 'Please select an item :'):
  5. self.widget = [
  6. {
  7. 'type':'list',
  8. 'name':'ans',
  9. 'message':question,
  10. 'choices':choices
  11. }
  12. ]
  13. def select(self):
  14. return prompt(self.widget)['ans']
  15. def selectInto(self, choices):
  16. self.widget[0]['choices'] = choices
  17. return self.select()