quantity_asker.py 503 B

12345678910111213141516171819202122
  1. from PyInquirer import prompt
  2. # Ask for a quantity
  3. class QuantityAsker:
  4. def __init__(self):
  5. self.widget = [
  6. {
  7. 'type':'input',
  8. 'name':'number',
  9. 'message':'Enter a quantity'
  10. }
  11. ]
  12. def askForOne(self, name):
  13. return int(prompt(self.widget)['number'])
  14. def askForEachOf(self, nameList):
  15. ans = []
  16. for name in nameList:
  17. ans.append(self.askForOne(name))
  18. return ans