from tkinter import *

def write(x):
    s = len(giris.get())
    giris.insert(s,str(x))
    print(x)

hesap = 5
s1 = 0

def actions(x):
    global hesap 
    hesap = x
    global s1
    s1 = int(giris.get())
    print(hesap)
    print(s1)
    giris.delete(0, 'end')

s2 = 0
def hesapla():
    global s2
    s2 = float(giris.get())
    print(s2)
    global hesap
    if (hesap == 0): sonuc = s1 + s2
    elif(hesap == 1): sonuc = s1 - s2
    elif(hesap == 2): sonuc = s1 * s2
    elif(hesap == 3): sonuc = s1 / s2


    giris.delete(0, 'end')
    giris.insert(0, str(sonuc))
    
    
    
    

window = Tk()
window.geometry("250x300")

giris = Entry(font = "Verdana 14 bold", width = 15, justify = RIGHT)
giris.place(x=20, y=20)


b = []

for i in range(1,10):
    b.append(Button(text = str(i), font = "Verdana 14 bold", command = lambda x=i:write(x)))
    
count = 0
for i in range (0,3):
    for j in range (0,3):
        b[count].place(x=20+j*50, y=50+i*50)
        count += 1


action = []

for i in range(0, 4):
    action.append(Button(font = "Verdana 14 bold", width = 2, command = lambda x=i:actions(x)))

action[0]['text'] = "+"
action[1]['text'] = "-"
action[2]['text'] = "*"
action[3]['text'] = "/"

for i in range(0,4):
    action[i].place(x = 170, y = 50+50*i)
    
sb = Button(text = 0, font = "Verdana 14 bold", command=lambda x=0:write(x))
sb.place(x = 20, y = 200)

nb = Button(text = ".", font = "Verdana 14 bold", width = 2, command = lambda x=".":write(x))
nb.place(x = 70, y = 200)

eb = Button(text = "=", fg = "GREEN", font = "Verdana 14 bold", command=hesapla)
eb.place(x = 120, y = 200)

    

window.mainloop()

