In: Computer Science
Make a menu for a restaurant using python. Make sure there are choices on the menu. Give me a little description of how you did it.
Programmed with PyCharm.
Code:
from tkinter import *
window=Tk()
window.title("Restaurant Menu and Billing") # Title of the window
window.geometry("450x500") # Geometry of the Window
# Function to Calculate the total amount
def calculate():
grilledShrimp = e1.get() # Get the quantity of Grilled Shrimp
chickenWings = e2.get() # Get the quantity of Chicken Wings
greekSalad = e3.get() # Get the quantity of Greek Salad
caesarSalad = e4.get() # Get the quantity of Caesar Salad
angusHamburger = e5.get() # Get the quantity of Angus Hamburger
meatballSandwich = e6.get() # Get the quantity of Meatball Sandwich
redmoorLinguine = e7.get() # Get the quantity of Redmoor Linguine
linguineandMeatballs = e8.get() # Get the quantity of Linguine and Meatballs
total=((int(grilledShrimp)*10) + (int(chickenWings)*11) + (int(greekSalad)*6) + (int(caesarSalad)*8) +
(int(angusHamburger)*9) + (int(meatballSandwich)*9) + (int(redmoorLinguine)*10) + (int(linguineandMeatballs)*14)) # Calculate total amount
label10 = Label(window, text =f"${total}", font="times 18").place(x=330, y =380) # Print total amount
# Labels that show the Items and their price
label0 = Label(window, text ="Menu", font="times 28 bold").place(x=150, y =30)
label9 = Label(window, text ="Item Price Qty", font="times 20 bold").place(x=90, y =80)
label1 = Label(window, text ="Grilled Shrimp $10", font="times 18").place(x=50, y =120)
label2 = Label(window, text ="Chicken Wings $11", font="times 18").place(x=50, y =150)
label3 = Label(window, text ="Greek Salad $6", font="times 18").place(x=50, y =180)
label4 = Label(window, text ="Caesar Salad $8", font="times 18").place(x=50, y =210)
label5 = Label(window, text ="Angus Hamburger $9", font="times 18").place(x=50, y =240)
label6 = Label(window, text ="Meatball Sandwich $9", font="times 18").place(x=50, y =270)
label7 = Label(window, text ="Redmoor Linguine $10", font="times 18").place(x=50, y =300)
label8 = Label(window, text ="Linguine and Meatballs $14", font="times 18").place(x=50, y =330)
label10 = Label(window, text ="Total: ", font="times 18").place(x=250, y =380)
# Entries that take in quantity as input
e1 = Entry(window, width=3)
e1.place(x=370, y=125)
e1.insert(0, "0") # Set zero as default value
e2 = Entry(window, width=3)
e2.place(x=370, y=155)
e2.insert(0, "0") # Set zero as default value
e3 = Entry(window, width=3)
e3.place(x=370, y=185)
e3.insert(0, "0") # Set zero as default value
e4 = Entry(window, width=3)
e4.place(x=370, y=215)
e4.insert(0, "0") # Set zero as default value
e5 = Entry(window, width=3)
e5.place(x=370, y=245)
e5.insert(0, "0") # Set zero as default value
e6 = Entry(window, width=3)
e6.place(x=370, y=275)
e6.insert(0, "0") # Set zero as default value
e7 = Entry(window, width=3)
e7.place(x=370, y=305)
e7.insert(0, "0") # Set zero as default value
e8 = Entry(window, width=3)
e8.place(x=370, y=335)
e8.insert(0, "0") # Set zero as default value
b1 = Button(window, text='Total', width=30, command=calculate).place(x=100, y=450) # Button when clicked displays the total amount
window.mainloop()
Output: