Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.9 kB
19
Indexable
Never
from tkinter import *
from PIL import ImageTk,Image
from tkinter.messagebox import askyesno

a=Tk()
c1=Canvas(a,width=250,height=250)
c1.grid(column=1,row=0)
img1=ImageTk.PhotoImage(Image.open("b1.png"))
c1.create_image(20,20,anchor=NW,imag=img1)

c2=Canvas(a,width=250,height=250)
c2.grid(column=2,row=0)
img2=ImageTk.PhotoImage(Image.open("ice.png"))
c2.create_image(20,20,anchor=NW,imag=img2)
#Menu Items
o=StringVar()
options=["Veg","Non-Veg",]
d1=OptionMenu(a,o,*options)
d1.grid(column=1,row=2)
o2=StringVar()
options2=["Chocolet","Vanilla",]
d2=OptionMenu(a,o2,*options2)
d2.grid(column=2,row=2)
#Qnty
q1=IntVar()
q1options=[1,2,3,4,5]
d3=OptionMenu(a,q1,*q1options)
d3.grid(column=1,row=3)

q22=IntVar()
q2options=[1,2,3,4,5]
d4=OptionMenu(a,q22,*q2options)
d4.grid(column=2,row=3)

lb3=Label(a,text="Cart : 0",font=("Arial Bold",25))
lb3.grid(column=4,row=0)
q=0
bill=0
bill2=0
def cart1():
    global q
    global v  
    global n
    global bill
    q=q1.get()
    lb3.configure(text="Cart : "+str(q))
    op=o.get()
    if op=="Veg":
       v=StringVar()
       veg=["Panner","Mashroom",]
       d5=OptionMenu(a,v,*veg)
       d5.grid(column=1,row=5)
       def veg():
           global v
           global n
           global bill
           global q
           
           vb=v.get()
           if vb=="Panner":
               bill=bill+(q*150)
           else:
               bill=bill+(q*170) 
       b1=Button(a,text="confirm",command=veg)
       b1.grid(column=1,row=6)
    
    else:
        n=StringVar()
        non=["Chicken ","Mutton",]
        d6=OptionMenu(a,n,*non)
        d6.grid(column=1,row=5)
        def nveg():
            global n
            global bill
            global q
            nb=n.get()
            if nb=="Chicken":
                bill=bill+(q*200)
            else:
                bill=bill+(q*250)
               
        b1=Button(a,text="confirm",command=nveg)
        b1.grid(column=1,row=6)
    
def cart2():
    global bill2
    global q22
    global q2
    global q
    global qn
    q2=q22.get()
    qn=q+q2
    lb3.configure(text="Cart : "+str(qn))
    f=o2.get()
    if f=="Chocolet":
        bill2=bill2+(q2*50)
    else:
        bill2=bill2+(q2*30)
    
    
    

b1=Button(a,text="Add to cart",bg="yellow",command=cart1)
b1.grid(column=1,row=4)
b2=Button(a,text="Add to cart",bg="yellow",command=cart2)
b2.grid(column=2,row=4)

def final():
    global q
    global q2
    global qn
    global bill
    global bill2
    t=bill+bill2
    ans=askyesno("",message="Hello\nCart :"+str(qn)+
                 "\n Total :"+str(t))
    if ans:
        messagebox.showinfo("","order done")
    else:
        messagebox.showerror("","order cancelled")
b3=Button(a,text="Proceed",bg="pink",command=final)
b3.grid(column=5,row=0)

a.mainloop()