house_asker.py 585 B

123456789101112131415161718192021
  1. from PyInquirer import prompt
  2. # Select a warehouse from a list
  3. class HouseAsker:
  4. def __init__(self):
  5. self.widget = [
  6. {
  7. 'type':'list',
  8. 'name':'ans',
  9. 'message':'Select a warehouse',
  10. 'choices':['No warehouse provided yet']
  11. }
  12. ]
  13. def select(self, rawHouseList):
  14. choices = []
  15. for h in rawHouseList:
  16. choices.append({'name':str(h[0]) + ':' + h[3], 'value': h[0]})
  17. self.widget[0]['choices'] = choices
  18. return prompt(self.widget)['ans']