product_select.py 610 B

123456789101112131415161718192021222324
  1. from PyInquirer import prompt
  2. # Select multiple items from a list
  3. class ProductSelecter:
  4. def __init__(self):
  5. self.widget = [
  6. {
  7. 'type':'checkbox',
  8. 'name':'ans',
  9. 'message':'Select products',
  10. 'choices':['No product']
  11. }
  12. ]
  13. def select(self):
  14. return prompt(self.widget)['ans']
  15. def selectInto(self, rawProList):
  16. choices = []
  17. for p in rawProList:
  18. choices.append({'key':p[0], 'name':p[1]})
  19. self.widget[0]['choices'] = choices
  20. return self.select()