This commit is contained in:
parent
910c446a2f
commit
bddaf5e7e9
|
@ -160,16 +160,20 @@ class Menu():
|
||||||
|
|
||||||
def input_choice(self, number_of_choices, prompt=None):
|
def input_choice(self, number_of_choices, prompt=None):
|
||||||
if prompt == None:
|
if prompt == None:
|
||||||
prompt = self.prompt
|
prompt = self.prompt
|
||||||
while True:
|
while True:
|
||||||
result = self.input_str(prompt)
|
result = self.input_str(prompt)
|
||||||
try:
|
if result == '':
|
||||||
choice = int(result)
|
print 'Please enter something'
|
||||||
if (choice > 0 and choice <= number_of_choices):
|
|
||||||
return choice
|
else:
|
||||||
except ValueError:
|
try:
|
||||||
pass
|
choice = int(result)
|
||||||
self.thing_in_menu_choice(result)
|
if (choice > 0 and choice <= number_of_choices):
|
||||||
|
return choice
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
self.thing_in_menu_choice(result)
|
||||||
|
|
||||||
|
|
||||||
def input_int(self, prompt=None, allowed_range=(None,None)):
|
def input_int(self, prompt=None, allowed_range=(None,None)):
|
||||||
|
@ -950,10 +954,10 @@ class ProductListMenu(Menu):
|
||||||
total_value += p.price*p.stock
|
total_value += p.price*p.stock
|
||||||
line_format = '%-15s | %5s | %-'+str(Product.name_length)+'s | %5s \n'
|
line_format = '%-15s | %5s | %-'+str(Product.name_length)+'s | %5s \n'
|
||||||
text += line_format % ('bar code', 'price', 'name', 'stock')
|
text += line_format % ('bar code', 'price', 'name', 'stock')
|
||||||
text += '-----------------------------------------------------------------------\n'
|
text += '-------------------------------------------------------------------------------\n'
|
||||||
for p in product_list:
|
for p in product_list:
|
||||||
text += line_format % (p.bar_code, p.price, p.name, p.stock)
|
text += line_format % (p.bar_code, p.price, p.name, p.stock)
|
||||||
text += '-----------------------------------------------------------------------\n'
|
text += '-------------------------------------------------------------------------------\n'
|
||||||
text += line_format % ('Total value',total_value,'','', )
|
text += line_format % ('Total value',total_value,'','', )
|
||||||
less(text)
|
less(text)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue