Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from guizero import *
- # Ice cream
- # Application
- color1 = "lightyellow"
- color2 = "orange"
- color3 = "lightgreen"
- color4 = "black"
- textsize1 = 18
- textsize2 = 16
- textsize3 = 14
- textsize4 = 12
- # Imports
- from guizero import App,Box,Text,CheckBox,\
- Combo,ListBox,Picture,PushButton,TextBox
- app =App(title='My ice-cream', bg=color1, layout='grid')
- def DarkMode():
- if Diary.value:
- app.bg = color2
- app.text_color = color1
- else:
- app.bg = color1
- app.text_color = color2
- def calculate():
- total = 0
- if waffle.value == 1:
- total += 0.40
- if glass.value == 1:
- total += 0.50
- if paper.value == 1:
- total += 0.75
- if flwn.value =="one":
- total += 0.40
- if flwn.value =="two":
- total += 0.70
- if flwn.value =="three":
- total += 0.90
- if orange.value ==1:
- total += 0.05
- if caramel.value ==1:
- total += 0.05
- if chocolate.value ==1:
- total += 0.20
- if fruits.value ==1:
- total += 0.10
- if strawbery.value ==1:
- total += 0.05
- if berries.value ==1:
- total += 0.30
- cost.value = total
- def enable():
- if cost.value == "0":
- Order.enabled=False
- if cost.value != 0:
- Order.enabled=True
- msg=info(app, text="Your ice cream will be ready in 2 minutes")
- text=Text(app, text="Let's order an ice-cream", size=textsize1, grid=[0,1,3,1])
- name_lbl=Text(app, text='What is your name?', grid=[0,2])
- name=TextBox(app, grid=[1,2])
- Diary = CheckBox(app, text="No diary products", grid=[0,3], command=DarkMode)
- # 3 images with ice cream waffle, glass, paper
- picture1 = Picture(app,image="C:/Folder/ic1.png", grid=[0,4], width=40, height=80)
- picture2 = Picture(app,image="C:/Folder/ic2.png", grid=[1,4], width=40, height=80)
- picture3 = Picture(app,image="C:/Folder/ic3.png", grid=[2,4], width=40, height=80)
- waffle = CheckBox(app, text="Waffle cone (0.40)", grid=[0,5], command=calculate)
- glass = CheckBox(app, text="Glass bowl (0.50)", grid=[1,5], command=calculate)
- paper = CheckBox(app, text="Take-away paper bowl (0.75)", grid=[2,5], command=calculate)
- flw1_lbl = Text(app, text="Flavour", grid=[0,6])
- flw = ListBox(app, items=["Vanilla", "Chocolate", "Pistachio", "Capuccino", "Strawberry", "Cherry", "Surprise"], grid=[1,6], command=calculate, multiselect=True)
- flwn = Combo(app, options=["one","two","three"], grid=[0,7])
- orange = CheckBox(app, text="Orange sauce (0.05)", grid=[0,8], command=calculate)
- caramel = CheckBox(app, text="Caramel sauce (0.05)", grid=[1,8], command=calculate)
- strawbery = CheckBox(app, text="Strawberry sauce (0.05)", grid=[2,8], command=calculate)
- fruits = CheckBox(app, text="Fruits (0.10)", grid=[0,9], command=calculate)
- chocolate = CheckBox(app, text="Chocolate (0.20)", grid=[1,9], command=calculate)
- berries = CheckBox(app, text="Berries (0.30)", grid=[2,9], command=calculate)
- cost_lbl = Text(app, text="Total cost of ice-cream:", grid=[0,10])
- cost = TextBox(app, text="0", grid=[1,10])
- btn_box = Box(app, grid=[0,12,3,1])
- Order = PushButton(btn_box, text="Order", align="left", command=enable)
- btn_box.bg="lightgreen"
- btn_box.text_color="orange"
- btn_box.text_size=24
- # End of script
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement