from tkinter import *
from PIL import ImageTk,Image

def click(event):
global scvalue
text = event.widget.cget("text")
print(text)
if text == "=":


if scvalue.get().isdigit():
valuue = int(scvalue.get())
else:
try:
value = eval(screen.get())

except Exception as e:
print(e)
scvalue.set("Error")
screen.update()

scvalue.set(value)
screen.update()

elif text == "C":
scvalue.set(" ")
screen.update()
pass

else:
scvalue.set(scvalue.get() + text)
screen.update()


root = Tk()
root.geometry("700x700")
root.title("Calculator made By Harsh Kumar")
root.wm_iconbitmap("2.ico")


scvalue = StringVar()
scvalue.set("")
screen = Entry(root, textvar=scvalue, font="DS-Digital 40 bold")
screen.pack(fill=X, ipadx=50, pady=50, padx=70)

f = Frame(root, bg="black")
b = Button(f, text="9", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="8", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="7", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="C", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="=", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)
f.pack()

f = Frame(root, bg="black")
b = Button(f, text="6", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="5", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="4", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="+", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="-", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)
f.pack()

f = Frame(root, bg="black")
b = Button(f, text="3", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="2", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="1", padx=17, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="*", padx=9, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="/", padx=11, pady=4, font="DS-Digital 38 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)
f.pack()

f = Frame(root, bg="black")
b = Button(f, text="0", padx=10, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="(", padx=16, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text=")", padx=16, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text=".", padx=16, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)

b = Button(f, text="%", padx=4, pady=4, font="DS-Digital 40 bold")
b.pack(side=LEFT, padx=4, pady=4)
b.bind("<Button-1>", click)
f.pack()

root.mainloop()