from tkinter import *
root=Tk()
root.geometry("280x607")
root.minsize(280,607)
root.maxsize(280,607)
root.title("Calculator by AlexDev")
root.configure(background="grey")
def click(event):
    global gvalue
    text=event.widget.cget("text")
    if text=="c":
        gvalue.set("")
        screen.update()
    elif text=="=":
        if gvalue.get().isdigit():
            value=int(gvalue.get())
        else:
            try:
                value=eval(screen.get())
            except Exception as e:
             print(e)
             value=("Error")
        gvalue.set(value)
        screen.update()
    else:
        gvalue.set(gvalue.get()+text)
gvalue=StringVar()
gvalue.set("")
screen=Entry(root,textvariable=gvalue,font="lucida 24 bold")
screen.pack(fill=X,padx=6,pady=16,ipady=8)
frame=Frame(root,background="grey")
buttton=Button(frame,text="7",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="8",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="9",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
frame.pack()
frame=Frame(root,background="grey")
buttton=Button(frame,text="4",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="5",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="6",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
frame.pack()
frame=Frame(root,background="grey")
buttton=Button(frame,text="1",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="2",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="3",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
frame.pack()
frame=Frame(root,background="grey")
buttton=Button(frame,text="+",padx=11,pady=12,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="-",padx=13,pady=11,font="lucida 25 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="*",padx=13,pady=12,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
frame.pack()
frame=Frame(root,background="grey")
buttton=Button(frame,text="/",padx=17,pady=9,font="lucida 22 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="%",padx=8,pady=11,font="lucida 21 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="=",padx=9,pady=9,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
frame.pack()
frame=Frame(root,background="grey")
buttton=Button(frame,text="c",padx=11,pady=11,font="lucida 23 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text=".",padx=12,pady=4,font="lucida 27 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
buttton=Button(frame,text="0",padx=13,pady=17,font="lucida 18 bold",bg="orange")
buttton.pack(side=LEFT,padx=5)
buttton.bind("<Button-1>",click)
frame.pack()
root.mainloop()
