From Tkinter Import
From Tkinter Import
root = Tk()
# dictionary
prices = {"COCA COLA": 8, "PEPSI COLA": 6, "ROYAL SODA": 5}
# FUNCTION
def add():
selected_drink = ds.cget("text")
ordered_drinks = otr.cget("text")
price = prices[selected_drink]
def remove():
selected_drink = ds.cget("text")
ordered_drinks = otr.cget("text")
price = prices[selected_drink]
def pay():
import tkinter as tk
class CashierMachine:
def __init__(self, root):
self.root = root
self.products = []
def add_product(self):
total = float(self.t_entry.get())
cash = float(self.csh_entry.get())
self.products.append((total, cash))
self.calculate_total()
def calculate_total(self):
v1 = float(self.t_entry.get())
v2 = float(self.csh_entry.get())
diff = v2 - v1
self.total_label.config(text="Total: ${:.2f}".format(diff), font= ("Times New Roman", "12", "bold"))
def print_receipt(self):
receipt = "************\nRECEIPT\n************\n\n"
total_cash = self.total_label
total_cash.configure(text=f"TOTAL CHANGE: " + str(total_cash))
receipt += "********"
self.receipt_text.delete("1.0", tk.END)
self.receipt_text.insert(tk.END, receipt)
self.t_entry.delete(0, tk.END)
self.csh_entry.delete(0, tk.END)
def c1():
ds.configure(text="COCA COLA", font=("Verdana", "11", "bold"), anchor=CENTER)
def c2():
ds.configure(text="PEPSI COLA", font=("Verdana", "11", "bold"), anchor=CENTER)
def c3():
ds.configure(text="ROYAL SODA", font=("Verdana", "11", "bold"), anchor=CENTER)
# main
mainf = ttk.Frame(root, width=800, height=800, style="df.TFrame")
mainf.grid(row=0, column=0, sticky=NSEW)
# mainframes
menuf = ttk.Frame(mainf, relief=SUNKEN, borderwidth=3)
menuf.grid(row=0, column=0, sticky=NSEW)
ordrf = ttk.Frame(mainf, style="df.TFrame", relief=GROOVE, borderwidth=3)
ordrf.grid(row=0, column=2, sticky=NSEW)
# dishframe
cd = ttk.Frame(menuf, style="mf.TFrame", relief=RAISED, borderwidth=3)
cd.grid(row=0, column=0, padx=3, pady=15, sticky=N)
c1f = ttk.Frame(menuf, style="mf.TFrame", relief=RAISED, borderwidth=3)
c1f.grid(row=1, column=0, padx=3, pady=15, sticky=NSEW)
c2f = ttk.Frame(menuf, style="mf.TFrame", relief=RAISED, borderwidth=3)
c2f.grid(row=2, column=0, padx=3, pady=15, sticky=NSEW)
c3f = ttk.Frame(menuf, style="mf.TFrame", relief=RAISED, borderwidth=3)
c3f.grid(row=3, column=0, padx=3, pady=15, sticky=NSEW)
cds = ttk.Frame(menuf, style="mf.TFrame", relief=RAISED, borderwidth=3)
cds.grid(row=4, column=0, padx=3, pady=15, sticky=NSEW)
# MENULABEL
ml = ttk.Label(cd, text="\t DRINKS ")
ml.config(font=("Verdana", "14", "bold"), anchor=CENTER)
ml.grid(row=0, column=0, pady=15, sticky="NSEW")
m1 = ttk.Label(c1f, text="\tCOCA-COLA ........ 8$\t", font=("Verdana", "10", "bold"))
m1.grid(row=1, column=0, pady=15, sticky="NSEW")
m2 = ttk.Label(c2f, text="\tPEPSI COLA ........ 6$\t", font=("Verdana", "10", "bold"))
m2.grid(row=2, column=0, pady=15, sticky="NSEW")
m3 = ttk.Label(c3f, text="\tROYAL SODA ....... 5$\t", font=("Verdana", "10", "bold"))
m3.grid(row=3, column=0, pady=15, sticky="NSEW")
ds = ttk.Label(cds)
ds.grid(row=4, column=0, pady=15, sticky="NSEW")
# ORDER FRAME
od = ttk.Label(ordrf, text=" ORDERED DRINKS ")
od.config(font=("Verdana", "14", "bold"), relief=SUNKEN, borderwidth=5, anchor=CENTER)
od.grid(row=0, column=0, columnspan=1, sticky=NSEW)
otr = ttk.Label(ordrf, text="")
otr.config(font=("Verdana", "8", "bold"), relief=SUNKEN, borderwidth=5)
otr.grid(row=1, column=0, rowspan=3, sticky=NSEW)
otl = ttk.Label(ordrf, text="TOTAL: 0.00$")
otl.config(font=("Verdana", "10", "bold"), relief=SUNKEN, borderwidth=5)
otl.grid(row=3, column=0, sticky=EW)
otl = ttk.Label(ordrf, text="TOTAL: 0.00$")
otl.config(font=("Verdana", "10", "bold"), relief=SUNKEN, borderwidth=5)
otl.grid(row=3, column=0, sticky=EW)
# butt
m1b = ttk.Button(c1f, text="SELECT", style="txt.TButton", command=c1)
m1b.grid(row=1, column=1, sticky=NSEW)
m2b = ttk.Button(c2f, text="SELECT", style="txt.TButton", command=c2)
m2b.grid(row=2, column=1, sticky=NSEW)
m3b = ttk.Button(c3f, text="SELECT", style="txt.TButton", command=c3)
m3b.grid(row=3, column=1, sticky=NSEW)
ab = ttk.Button(ordrf, text="ADD ITEM", style="txt.TButton", command=add)
ab.grid(row=4, column=0, sticky="EW")
rb = ttk.Button(ordrf, text="REMOVE", style="txt.TButton", command=remove)
rb.grid(row=5, column=0, sticky="EW")
pb = ttk.Button(ordrf, text="PAY", style="txt.TButton", command=pay)
pb.grid(row=6, column=0, sticky="EW")
# configs
c = ttk.Style()
c.configure("mf.TFrame", background="#2B2A4C")
c.configure("mnf.TFrame", background="#EEE2DE")
c.configure("df.TFrame", background="#EA906C")
c.configure("of.TFrame", background="#B31312")
c.configure("txt.TButton", font=("Helvetica", "8", "bold"), background="#EA906C")
ordrf.columnconfigure(0, weight=1)
ordrf.rowconfigure(2, weight=1)
root.mainloop()