NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

fatihtastemur / tk.hesap_makinesi.py
Sign in
Sign up
Tkinter ile görsel hesap makinesi..
tk.hesap_makinesi.py
#!/usr/bin/env python
#-*- coding:utf-8-*-

from Tkinter import *

def yaz(x):
global yazi
yazi=yazi + x
ekran.config(text=yazi)

def hesapla():
global yazi
a=eval(yazi)
ekran.config(text=a)
yazi=""

def temizle():
global yazi
ekran.config(text="")
yazi=""

def sil():
global yazi
yazi=yazi[0:-1]
ekran.config(text=yazi)
#bu bolumde hesap makinemizin isleyisi yer aliyor..

ftastemur=Tk()
ftastemur.geometry("340x280")
ftastemur.resizable(width=FALSE, height=FALSE)
ftastemur.title("hesap makinesi")
#ftastemur isimli bir pencere olusturduk.
#geometry komutu ile pencerenin boyutlarini belirttik.
#resizable komutu ile pencere boyutunun erisimini belirledik.
#FALSE erisime kapali(degistirilemez) anlamina gelmektedir..
#title ile pencereye bir baslik verdik.

cerceveana1=Frame()
cerceveana1.pack(expand=YES, fill=X)
#Frame() komutuyla bir cerceve olusturduk.
#pack bu cerceveyi gormemizi saglar.
#expand(); cercevenin pencere icerisindeki konumunu belirtir.
#expand=ortasinda olsun anlamina gelir.
#fill komutu cercevenin hangi eksende doldurulacagini belirtir.
#fill=X,Y,BOTH(x ekseni,y ekseni,her iki eksen) olabilir.

cerceveana11=Frame(cerceveana1)
cerceveana11.pack(side=TOP, expand=YES, fill=X)
#side yine cercevenin konumunu belirtir.
#side=TOP cerceve ust tarafa yaslanmis olsun anlaminda.
#side=(TOP,BOTTOM,LEFT,RIGHT) olabilir..
#sirasiyla(ust,alt,sol,sag)


cerceveana2=Frame()
cerceveana2.pack()

cerceveana21=Frame(cerceveana2)
cerceveana21.grid(row=0, column=0)
#grid() pencere araclarinin siralanacagi bir yapi.
#row=satir column=sutun
#yani cerceveana21 cerceveana2'nin 0.satir,0.sutun'unda yer alsin..

cerceveana22=Frame(cerceveana2)
cerceveana22.grid(row=0, column=1)

cerceveana23=Frame(cerceveana2)
cerceveana23.grid(row=1, column=0)

cerceveana24=Frame(cerceveana2)
cerceveana24.grid(row=1, column=1)

cerceve4=Frame(cerceveana21)
cerceve4.pack(padx=12)

cerceve2=Frame(cerceveana22)
cerceve2.pack(padx=12)

yazi=""
ekran=Label(cerceveana11)
ekran.config(textvariable=yazi,relief=SUNKEN,bg="#ffffff",height=2,anchor=E)
ekran.pack(expand=YES, fill=X, padx=12, pady=10)
#relief ile cercevemizin kabartma tipini belirledik..
#kabartma tipleri SUNKEN,SOLID,FLAT,RIDGE,GROOVE,RAISED...olabilir.

ben1=Label(cerceveana23)
ben1.config(text="Fatih TASTEMUR", fg="black", bg="green", font=("Monotype Corsiva", 14, "italic"))
ben1.pack()
#config() komutu ile olusturdugumuz ben1 etiketini cerceveana23'e bagladik.
#font() komutuylada etiketimizin yazi tipini ve buyuklugunu belirttik.

ben2=Label(cerceveana24)
ben2.config(text="OMU_CENG19", fg="black", bg="green", font=("Monotype Corsiva", 14, "italic"))
ben2.pack()
#pack() yaptigimiz cerceve,dugum,etiket..vs. goruntulememizi sagliyor..!
#pack yazmazsak kodu calistirdigimizda hic bir sey goremeyiz..


c=0
d=0
e=0
for i in (1,2,3,4,5,6,7,8,9):
k=i%3
if k==1:
Button(cerceve4, text=i,fg="white",bg="blue",font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz(str(i)))).grid(row=c, column=1)
c=c+1
if k==2:
Button(cerceve4, text=i,fg="white",bg="blue",font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz(str(i)))).grid(row=d, column=2)
d=d+1
if k==0:
Button(cerceve4, text=i,fg="white",bg="blue",font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz(str(i)))).grid(row=e, column=3)
e=e+1
#burda kullanacagimiz rakamlari yazdik lambda notasyonu yardimiyla..
#height-width kullanacagimiz butonlarin(cerceve dugumleri) eni ve boyu olarak dusunulebilir..


Button(cerceve2, text="X",fg="yellow",bg="red", font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz("*"))).grid(row=0, column=4)
Button(cerceve2, text="/",fg="yellow",bg="red", font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz("/"))).grid(row=1, column=4)
Button(cerceve2, text="=", fg="yellow",bg="red",font=("Arial", 10, "bold"), height=2, width=6, command=hesapla).grid(row=2, column=4)
Button(cerceve4, text="(",fg="white",bg="blue", font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz("("))).grid(row=3, column=1)
Button(cerceve4, text="0",fg="white",bg="blue", font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz("0"))).grid(row=3, column=2)
Button(cerceve4, text=")",fg="white",bg="blue", font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz(")"))).grid(row=3, column=3)
Button(cerceve2, text="AC",fg="yellow",bg="red", font=("Arial", 10, "bold"), height=2, width=6, command=temizle).grid(row=3, column=4)
Button(cerceve2, text="+",fg="yellow",bg="red", font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz("+"))).grid(row=0, column=5)
Button(cerceve2, text="-",fg="yellow",bg="red", font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz("-"))).grid(row=1, column=5)
Button(cerceve2, text=".",fg="yellow",bg="red",font=("Arial", 10, "bold"), height=2, width=6, command=(lambda i=i: yaz("."))).grid(row=2, column=5)
Button(cerceve2, text="C", fg="yellow",bg="red", font=("Arial", 10, "bold"), height=2, width=6, command=sil).grid(row=3, column=5)
#burdada isleclerimiz var..
#fg(frontground)=on plan rengi..
#bg(background)=arka plan rengi..
#font() komutu ile yine yazi tipini belirledik..
#grid() komutu ile islec butonlarinin konumunu belirttik..
#row=satir,column=sutun

ftastemur.mainloop()
Comment on gist
Sign in to comment
or sign up to join this conversation on GitHub
Desktop version
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.