book_asker.py 611 B

12345678910111213141516171819202122
  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. self.widget[0]['choices'] = []
  15. for rb in bookList:
  16. dic = {'key': rb[0], 'value': rb[0], 'name': str(rb[0]) + ' : ' + str(rb[1].isoformat())}
  17. self.widget[0]['choices'].append(dic)
  18. return prompt(self.widget)['id']