Advertisement
davidhellam

Python: Ice Cream Selector

Aug 10th, 2019
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.87 KB | None | 0 0
  1. from guizero import App, Text, Slider, CheckBox, TextBox, PushButton, Combo
  2.  
  3. def doCalc():
  4.     tb_name.text_color = "red"
  5.     total=0
  6.     scoops=int(sl_scoops.value)
  7.     if(cb_flavour.value=="Vanilla"):
  8.         icecream=50
  9.     else:
  10.         icecream=60
  11.     if (cb_sauce.value=="None"):
  12.         sauce=0
  13.     else:
  14.         sauce=20
  15.     if (cb_extras.value=="None"):
  16.         extras=0
  17.     elif(cb_extras.value=="Flake"):
  18.          extras=30
  19.     elif(cb_extras.value=="Chopped Nuts"):
  20.         extras=20
  21.     elif(cb_extras.value=="Sprinkles"):
  22.         extras=10
  23.     total = float(scoops*icecream+sauce+extras)/100
  24.     tx_total.value="£"+str(total)+"0"
  25.     tx_total.size=24
  26.     tx_total.show()
  27.  
  28.  
  29. app = App(title='Ice Cream App', bg="white", width=240, height=480)
  30. app.text_color="blue"
  31. tx_title = Text(app, text="Choose Your Ice Cream", size=14)
  32. tx_title.text_color = "black"
  33. tx_underline = Text(app, text="------------------------" , size=18)
  34. tx_underline.text_color = "white"
  35. tx_underline.bg = "black"
  36. tx_name = Text(app, text="Give Your Ice Cream a Name:")
  37. tx_name.text_color = "blue"
  38. tb_name = TextBox(app,text="Crunchy Slime", width =20)
  39. tx_scoops = Text(app, text="How Many Scoops:")
  40. tx_scoops.text_color = "blue"
  41. sl_scoops=Slider(app,start=1,end=4,horizontal=True)
  42. tx_flavour=Text(app, text="Ice Cream Flavour")
  43. tx_flavour.text_color = "blue"
  44. cb_flavour=Combo(app,options=["Vanilla","Chocolate","Strawberry"])
  45. tx_sauce=Text(app,text="Sauce:")
  46. tx_sauce.text_color = "blue"
  47. cb_sauce=Combo(app,options=["None","Chocolate","Monkey Blood","Alien Juice"],selected="None")
  48. tx_extras=Text(app,text="Extras:")
  49. tx_extras.text_color = "blue"
  50. cb_extras=Combo(app,options=["None","Flake","Chopped Nuts","Sprinkles"],selected="None")
  51. bt_calc = PushButton(app, command = doCalc, text='Calculate Price')
  52. tx_total = Text(app, text="price goes here")
  53. tx_total.hide()
  54. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement