exp=""
from tkinter import*
from tkinter.ttk import*
main_window=Tk()
main_window.geometry('874x492')
main_window.title("calculator")
def valuepress(num):
    global exp
    exp=exp+str(num)
    str_var.set(exp)
def equalpress():
    try:
        global exp
        answer=str(eval(exp))
        str_var.set(answer)
        exp=""
    except:
        str_var.set("invalid")
        exp=""
def clear():
    global exp
    exp=""
    str_var.set(exp)
        
#img1=PhotoImage(file="C:/Users/user/Downloads/Financial-big-874x492.png")
#img=PhotoImage(file="C:/Users/user/Downloads/187161.png")
#label=Label(main_window,image=img)
#label.place(x=0,y=0)
#label1=Label(main_window,image=img1)
#label1.place(x=250,y=200)
label2=Label(main_window,text="calculator",font="verdana 50")
label2.place(x=500,y=50)
str_var=StringVar()
box=Entry(main_window,font=("courier 50 bold"),textvariable=str_var)
box.place(x=400,y=210,height=60,width=600)
s=Style()
s.configure('TButton',font=("arial",15,"bold"))
btn=Button(main_window,text="1",style="TButton",command=lambda:valuepress(1)) 
btn.place(x=320,y=300)
btn=Button(main_window,text="2",command=lambda:valuepress(2)) 
btn.place(x=520,y=300)
btn=Button(main_window,text="3",command=lambda:valuepress(3)) 
btn.place(x=720,y=300)
btn=Button(main_window,text="4",command=lambda:valuepress(4)) 
btn.place(x=920,y=300)
btn=Button(main_window,text="5",command=lambda:valuepress(5)) 
btn.place(x=320,y=400)
btn=Button(main_window,text="6",command=lambda:valuepress(6))
btn.place(x=520,y=400)
btn=Button(main_window,text="7",command=lambda:valuepress(7)) 
btn.place(x=720,y=400)
btn=Button(main_window,text="8",command=lambda:valuepress(8)) 
btn.place(x=920,y=400)
btn=Button(main_window,text="9",command=lambda:valuepress(9)) 
btn.place(x=320,y=500)
btn=Button(main_window,text="0",command=lambda:valuepress(0)) 
btn.place(x=520,y=500)
btn=Button(main_window,text="+",command=lambda:valuepress("+")) 
btn.place(x=720,y=500)
btn=Button(main_window,text="-",command=lambda:valuepress("-")) 
btn.place(x=920,y=500)
btn=Button(main_window,text="*",command=lambda:valuepress("*")) 
btn.place(x=320,y=600)
btn=Button(main_window,text="/",command=lambda:valuepress("/")) 
btn.place(x=520,y=600)
btn=Button(main_window,text="%",command=lambda:valuepress("%")) 
btn.place(x=720,y=600)
btn=Button(main_window,text=".",command=lambda:valuepress("."))
btn.place(x=920,y=600)
btn=Button(main_window,text="=",command=equalpress) 
btn.place(x=720,y=650)
btn=Button(main_window,text="clear",command=clear) 
btn.place(x=520,y=650)



main_window.mainloop()
