This commit is contained in:
Ine Beate Larsen 2011-03-06 13:53:01 +00:00
parent 910c446a2f
commit bddaf5e7e9
1 changed files with 14 additions and 10 deletions

View File

@ -163,6 +163,10 @@ class Menu():
prompt = self.prompt prompt = self.prompt
while True: while True:
result = self.input_str(prompt) result = self.input_str(prompt)
if result == '':
print 'Please enter something'
else:
try: try:
choice = int(result) choice = int(result)
if (choice > 0 and choice <= number_of_choices): if (choice > 0 and choice <= number_of_choices):
@ -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)