create a GUI tkinter application using Python. It is for a coffee ordering site. The options are
Question:
create a GUI tkinter application using Python. It is for a coffee ordering site. The options are hot or iced. Basically, the total comes out incorrectly if I just order a hot coffee or just order an iced coffee. In order for the code to correctly calculate the total - I have to get both hot and iced. Is there any suggestions that I can add to make it more realistic?
Please see code here:
import tkinter as tk from tkinter import * from tkinter import messagebox from PIL import ImageTk, Image
#creating the root window root=tk.Tk() root.title("A Coffee Lovers Dream!") root.iconbitmap('c:/gui/favicon.ico') root.minsize(700,500)
label1=tk.Label(root,text="Welcome to Kat's Coffee",font=("Arial", 30)) label1.place(x=50,y=50) label2=tk.Label(root,text="Please see our Menu:",font=("Arial", 15)) label2.place(x=50,y=170) label3=tk.Label(root,text="Iced Coffee: Vanilla Latte, Cinnamon Latte, White Chocolate Mocha",font=("Arial", 15)) label3.place(x=50,y=200) label4=tk.Label(root,text="Hot Coffee: Americano, Black Coffee",font=("Arial", 15)) label4.place(x=50,y=230) label5=tk.Label(root,text="Enter iced Coffee names(using comma)",font=("Arial", 15)) label5.place(x=60,y=280) entry1=tk.Entry(root,font=("Arial", 15)) entry1.place(x=420,y=280) label6=tk.Label(root,text="Enter Hot Coffee names(using comma)",font=("Arial", 15)) label6.place(x=70,y=310) entry2=tk.Entry(root,font=("Arial", 15)) entry2.place(x=420,y=310)
def calc():
s1=entry1.get() s2=entry2.get() Iced=s1.split(sep=',') Hot=s2.split(sep=',') len1=len(Iced) len2=len(Hot) priceOfIced=len1*4.99 priceOfHot=len2*1.99
s='price of Iced : {} price of Hot : {}'.format(priceOfIced,priceOfHot) messagebox.showinfo('Price of Drinks',s) return priceOfIced,priceOfHot,Iced,Hot
def total():
price_iced,price_hot,iced,hot=calc() total=price_iced+price_hot s='Total price : {:5.2f}'.format(total) child_w= Toplevel(root) child_w.geometry("350x350") child_w.grid_location(x=300,y=300) child_w.title("Total Price")
label_child= Label(child_w, text= s, font=('Helvetica 15')) label_child.place(x=20,y=50) label7= Label(child_w, text="Order complete, Please see cashier", font=('Helvetica 15')) label7.place(x=20,y=100)
s2=' '.join(priceOfIced)+" "+' '.join(priceOfHot) label8= Label(child_w, text=s2, font=('Helvetica 15')) label8.place(x=20,y=150)
button1 = tk.Button(root,text="Calculate price of Iced and Hot drinks",command=calc,font=("Arial", 15)) button1.place(x=100,y=380) button2 = tk.Button(root,text="Complete Order",command=total,font=("Arial", 15)) button2.place(x=100,y=420) button3 = tk.Button(root,text="Exit Site",command=root.destroy,font=("Arial", 15)) button3.place(x=100,y=460)
root.mainloop()
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young