Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from guizero import App, Text, Slider, CheckBox, TextBox, PushButton, Combo
- def doCalc():
- tb_name.text_color = "red"
- total=0
- scoops=int(sl_scoops.value)
- if(cb_flavour.value=="Vanilla"):
- icecream=50
- else:
- icecream=60
- if (cb_sauce.value=="None"):
- sauce=0
- else:
- sauce=20
- if (cb_extras.value=="None"):
- extras=0
- elif(cb_extras.value=="Flake"):
- extras=30
- elif(cb_extras.value=="Chopped Nuts"):
- extras=20
- elif(cb_extras.value=="Sprinkles"):
- extras=10
- total = float(scoops*icecream+sauce+extras)/100
- tx_total.value="£"+str(total)+"0"
- tx_total.size=24
- tx_total.show()
- app = App(title='Ice Cream App', bg="white", width=240, height=480)
- app.text_color="blue"
- tx_title = Text(app, text="Choose Your Ice Cream", size=14)
- tx_title.text_color = "black"
- tx_underline = Text(app, text="------------------------" , size=18)
- tx_underline.text_color = "white"
- tx_underline.bg = "black"
- tx_name = Text(app, text="Give Your Ice Cream a Name:")
- tx_name.text_color = "blue"
- tb_name = TextBox(app,text="Crunchy Slime", width =20)
- tx_scoops = Text(app, text="How Many Scoops:")
- tx_scoops.text_color = "blue"
- sl_scoops=Slider(app,start=1,end=4,horizontal=True)
- tx_flavour=Text(app, text="Ice Cream Flavour")
- tx_flavour.text_color = "blue"
- cb_flavour=Combo(app,options=["Vanilla","Chocolate","Strawberry"])
- tx_sauce=Text(app,text="Sauce:")
- tx_sauce.text_color = "blue"
- cb_sauce=Combo(app,options=["None","Chocolate","Monkey Blood","Alien Juice"],selected="None")
- tx_extras=Text(app,text="Extras:")
- tx_extras.text_color = "blue"
- cb_extras=Combo(app,options=["None","Flake","Chopped Nuts","Sprinkles"],selected="None")
- bt_calc = PushButton(app, command = doCalc, text='Calculate Price')
- tx_total = Text(app, text="price goes here")
- tx_total.hide()
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement