Advertisement
jolgri

Assignment 8 ice cream

Jan 1st, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. from guizero import *
  2.  
  3. # Ice cream
  4. # Application
  5. color1 = "lightyellow"
  6. color2 = "orange"
  7. color3 = "lightgreen"
  8. color4 = "black"
  9.  
  10. textsize1 = 18
  11. textsize2 = 16
  12. textsize3 = 14
  13. textsize4 = 12
  14.  
  15. # Imports
  16. from guizero import App,Box,Text,CheckBox,\
  17. Combo,ListBox,Picture,PushButton,TextBox
  18.  
  19. app =App(title='My ice-cream', bg=color1, layout='grid')
  20.  
  21. def DarkMode():
  22. if Diary.value:
  23. app.bg = color2
  24. app.text_color = color1
  25. else:
  26. app.bg = color1
  27. app.text_color = color2
  28.  
  29. def calculate():
  30. total = 0
  31. if waffle.value == 1:
  32. total += 0.40
  33. if glass.value == 1:
  34. total += 0.50
  35. if paper.value == 1:
  36. total += 0.75
  37. if flwn.value =="one":
  38. total += 0.40
  39. if flwn.value =="two":
  40. total += 0.70
  41. if flwn.value =="three":
  42. total += 0.90
  43. if orange.value ==1:
  44. total += 0.05
  45. if caramel.value ==1:
  46. total += 0.05
  47. if chocolate.value ==1:
  48. total += 0.20
  49. if fruits.value ==1:
  50. total += 0.10
  51. if strawbery.value ==1:
  52. total += 0.05
  53. if berries.value ==1:
  54. total += 0.30
  55.  
  56. cost.value = total
  57.  
  58. def enable():
  59. if cost.value == "0":
  60. Order.enabled=False
  61. if cost.value != 0:
  62. Order.enabled=True
  63. msg=info(app, text="Your ice cream will be ready in 2 minutes")
  64.  
  65.  
  66. text=Text(app, text="Let's order an ice-cream", size=textsize1, grid=[0,1,3,1])
  67.  
  68. name_lbl=Text(app, text='What is your name?', grid=[0,2])
  69. name=TextBox(app, grid=[1,2])
  70.  
  71. Diary = CheckBox(app, text="No diary products", grid=[0,3], command=DarkMode)
  72.  
  73. # 3 images with ice cream waffle, glass, paper
  74. picture1 = Picture(app,image="C:/Folder/ic1.png", grid=[0,4], width=40, height=80)
  75. picture2 = Picture(app,image="C:/Folder/ic2.png", grid=[1,4], width=40, height=80)
  76. picture3 = Picture(app,image="C:/Folder/ic3.png", grid=[2,4], width=40, height=80)
  77.  
  78.  
  79. waffle = CheckBox(app, text="Waffle cone (0.40)", grid=[0,5], command=calculate)
  80. glass = CheckBox(app, text="Glass bowl (0.50)", grid=[1,5], command=calculate)
  81. paper = CheckBox(app, text="Take-away paper bowl (0.75)", grid=[2,5], command=calculate)
  82.  
  83. flw1_lbl = Text(app, text="Flavour", grid=[0,6])
  84.  
  85. flw = ListBox(app, items=["Vanilla", "Chocolate", "Pistachio", "Capuccino", "Strawberry", "Cherry", "Surprise"], grid=[1,6], command=calculate, multiselect=True)
  86. flwn = Combo(app, options=["one","two","three"], grid=[0,7])
  87.  
  88. orange = CheckBox(app, text="Orange sauce (0.05)", grid=[0,8], command=calculate)
  89. caramel = CheckBox(app, text="Caramel sauce (0.05)", grid=[1,8], command=calculate)
  90. strawbery = CheckBox(app, text="Strawberry sauce (0.05)", grid=[2,8], command=calculate)
  91. fruits = CheckBox(app, text="Fruits (0.10)", grid=[0,9], command=calculate)
  92. chocolate = CheckBox(app, text="Chocolate (0.20)", grid=[1,9], command=calculate)
  93. berries = CheckBox(app, text="Berries (0.30)", grid=[2,9], command=calculate)
  94.  
  95. cost_lbl = Text(app, text="Total cost of ice-cream:", grid=[0,10])
  96. cost = TextBox(app, text="0", grid=[1,10])
  97.  
  98.  
  99. btn_box = Box(app, grid=[0,12,3,1])
  100. Order = PushButton(btn_box, text="Order", align="left", command=enable)
  101. btn_box.bg="lightgreen"
  102. btn_box.text_color="orange"
  103. btn_box.text_size=24
  104.  
  105. # End of script
  106. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement