book_asker.py 546 B

123456789101112131415161718192021
  1. from PyInquirer import prompt
  2. # Select a bookorder
  3. class BookAsker:
  4. def __init__(self):
  5. self.widget = [
  6. {
  7. 'type':'list',
  8. 'name':'id',
  9. 'message':'Which book order do you want to examine ?',
  10. 'choices':[]
  11. }
  12. ]
  13. def select(self, bookList):
  14. for rb in bookList:
  15. dic = {'key': rb[0], 'value': rb[0], 'name': rb[1].isoformat()}
  16. self.widget[0]['choices'].append(dic)
  17. return prompt(self.widget)['id']