Python ile basit hesap makinesi yapımı

 Python Tkinder kütüphanesi ile basit hesap makinesi




Python tkinter kütüphanesi basit bir arayüz tasarlama kütüphanesidir. Bu kütüphaneyi kullanarak kendi arayüzünüzü oluşturabilirsiniz.Daha önce HTML ve CSS ile kod yazmış kişiler kolaylıkla adapte olurlar. 


Kodları

from tkinter import*


def toplama():
s1=float(gırıs.get())
s2=float(gırıs1.get())
sonuc.configure(text=str(s1+s2))
def cıkarma():
s1 = float(gırıs.get())
s2 = float(gırıs1.get())
sonuc.configure(text=str(s1 - s2))

def bolme():
s1 = float(gırıs.get())
s2 = float(gırıs1.get())
sonuc.configure(text=str(s1 / s2))

def carpma():
s1 = float(gırıs.get())
s2 = float(gırıs1.get())
sonuc.configure(text=str(s1 * s2))

def temızle():
gırıs.delete(0, END)
gırıs1.delete(0, END)







goruntu=Tk()
goruntu.geometry("300x300")
goruntu.resizable(height="FALSE", width="FALSE")
back_ground=Label(bg='#cd5c5c')
back_ground.place(height=300, width=300)

gırıs=Entry(width=43, justify=RIGHT)
gırıs.place(x=20, y=20, height=30)
gırıs1=Entry(width=43, justify=RIGHT)
gırıs1.place(x=20, y=60, height=30)

top=Button(text="+", font="verdana 14 bold", bg="#8470ff", command=toplama)
top.place(x=110, y=110, height=50, width=50)

cık=Button(text="-", font="verdana 14 bold", bg="#8470ff", command=cıkarma)
cık.place(x=110, y=160, height=50, width=50)

bol=Button(text="/", font="verdana 14 bold", bg="#8470ff", command= bolme)
bol.place(x=60, y=160, height=50, width=50)

carp=Button(text="*", font="verdana 14 bold", bg="#8470ff", command=carpma)
carp.place(x=60, y=110, height=50, width=50)

sonuc=Label(text="SONUC", bg='#cd5c5c', justify="center", font="verdana 10 bold")
sonuc.place(x=170, y=110)

temızle=Button(text="Temizle", font="verdana 12 bold", bg="#8470ff", command=temızle)
temızle.place(x=60, y=210, width=100, height=40)
goruntu.mainloop()

Yorumlar