Question: #import tkinter: from tkinter import * #import messagebox for displaying message: from tkinter import messagebox root = Tk ( ) root.geometry ( ' 6 2
#import tkinter:
from tkinter import
#import messagebox for displaying message:
from tkinter import messagebox
root Tk
root.geometryx #Declares the size
# Assign Title and background color
root.titleSweet Scoops"
root.configurebg#ebd
# Header label
purchaseEntry StringVar
banner Labelroot text"Sweet Scoops Ice Cream", bg#feeb fg"blue", padx pady fontGeorgia 'bold'
banner.placex y
# Name label and entry box
scoopLabel Labelroot text"Enter # of Scoops Desired:", bg"white", fg"black"
scoopLabel.placex y
scoopTextbox Entryroot width
scoopTextbox.placex y
# Create Flavor label:
flavorLabel Labelroot text"Select a Flavor:", bg"white", fg"black"
flavorLabel.placex y
#Create Flavor List Selection:
flavorList Chocolate "Vanilla", "Strawberry"
flavorString StringVar
#Create a ListBox for User to CLick on the Selected Ice Cream Flavor:
flavor Listboxroot width height listvariableflavorString, exportselection
flavor.placex y
flavorString.setflavorList
flavor.selectset
# Create Toppings label:
toppingLabel Labelroot text"Select Toppings:", bg"white", fg"black"
toppingLabel.placex y
#Create Topping List Selection For User to Select:
toppingList Sprinkles "Caramel Syrup", "Chocolate Syrup", "None"
toppingString StringVar
#Create a ListBox for User to CLick on the Selected Ice Cream Toppings:
toppingSides Listboxroot width height listvariabletoppingString, exportselection
toppingSides.placex y
toppingString.settoppingList
toppingSides.selectset
# Total label and entry box
subtotalLabel Labelroot text"SUBTOTAL:", bg"white", fg"black"
subtotalLabel.placex y
subtotalEntry Entryroot width
subtotalEntry.placex y
# Sales Tax label and entry box
taxLabel Labelroot text"SALES TAX:", bg"white", fg"black"
taxLabel.placex y
taxEntry Entryroot width
taxEntry.placex y
# Total Cost label and entry box
totalLabel Labelroot text"TOTAL COST:", bg"white", fg"black"
totalLabel.placex y
totalEntry Entryroot width
totalEntry.placex y
# Define total and Price values for Flavor and Topping Dictionary:
def total:
flavorDict Chocolate: 'Vanilla' : 'Strawberry':
toppingDict Sprinkles: 'Caramel Syrup': 'Chocolate Syrup': 'None':
#Clear out the Entry Fields for Subtotal,Tax, and Total:
subtotalEntry.delete END
taxEntry.delete END
totalEntry.delete END
#Get st and nd selctions from User:
selection flavor.curselection
flavorValue flavor.getselection
selection toppingSides.curselection
toppingValue toppingSides.getselection
#Loop for empty input for number of Scoops, Messagebox is displayed with message:
numberScoops scoopTextbox.get
if not numberScoops.isdigit:
messagebox.showinfotitle"Please enter # of ice cream scoops", message"Please enter a whole number."
return
#Convert string to Integer:
numberScoops intnumberScoops
#Define Subtotal, Sales Tax, and Total Cost:
subtotal flavorDictflavorValue numberScoops toppingDicttoppingValue
subtotal roundsubtotal #Use round function to round subtotal to decimal places
salesTax roundsubtotal #Use round function to round salesTax to decimal places
totalCost roundsubtotal salesTax, #Use round function to round total cost to decimal places
#Enter the correct formatted subtotal, salesTax, and totalCost into the entry boxes:
subtotalEntry.insertEND$:fformatsubtotal
taxEntry.insertEND$:fformatsalesTax
totalEntry.insertEND$:fformattotalCost
printRestaurant name: banner.cgettext
printNumber of Ice Cream Scoops: numberScoops
printFlavor of Ice Cream: flavorValue
printToppings on Ice Cream: toppingValue
print
printSubTotal: $ subtotal
printSales Tax: $ salesTax
printTotal Cost: $ totalCost
printThank you for using our Sweet Scoops App! Hope to see you soon!"
#Create button for Adding user selections to find the subtotal, sales tax, and total cost:
addButton Buttonroot text"Add to the order", bg"blue", fg"black", commandtotal
addButton.placex y
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
