Thinker & Sqlite3
from tkinter import *
import sqlite3
connection = sqlite3.connect ("Kisiler.db")
cursor = connection.cursor ()
root = Tk ()
root.geometry ("400x300")
root.config (bg="SlateGray3")
root.title('Kişi Bilgileri')
frame = Frame(root)
frame.place(x=30, y=150)
scroll = Scrollbar(frame, orient=VERTICAL)
select = Listbox(frame, yscrollcommand=scroll.set, height=5, width=50)
scroll.config (command=select.yview)
scroll.pack(side=RIGHT, fill=Y)
select.pack(side=LEFT, fill=BOTH, expand=1)
KisiAdi = StringVar ()
KisiSoyadi = StringVar ()
DogumYeri = StringVar ()
DogumTarihi = StringVar ()
def Ekle():
komut = """insert into Kisiler (KisiID, KisiAdi, KisiSoyadi, DogumYeri, DogumTarihi)
VALUES (?, ?, ?, ?, ?);"""
parametreler = [None, KisiAdi.get(), KisiSoyadi.get(), DogumYeri.get(), DogumTarihi.get()]
cursor.execute (komut, parametreler)
connection.commit()
def Guncelle():
komut = """Update Kisiler
set DogumYeri = ?, DogumTarihi = ?
where KisiAdi = ? and KisiSoyadi = ?;"""
parametreler = [DogumYeri.get(), DogumTarihi.get(), KisiAdi.get(), KisiSoyadi.get()]
cursor.execute (komut, parametreler)
connection.commit()
def Sorgula():
komut = """select DogumYeri, DogumTarihi
from Kisiler
where KisiAdi = ? and KisiSoyadi = ?;"""
parametreler = [KisiAdi.get(), KisiSoyadi.get()]
Kayitlar = cursor.execute (komut, parametreler)
for Kayit in Kayitlar:
DogumYeri.set (Kayit[0])
DogumTarihi.set (Kayit[1])
connection.commit()
def Sil():
komut = """delete from Kisiler
where KisiAdi = ? and KisiSoyadi = ?;"""
parametreler = [KisiAdi.get(), KisiSoyadi.get()]
cursor.execute (komut, parametreler)
connection.commit ()
def Cik():
root.destroy()
def Listele() :
komut = """select KisiAdi, KisiSoyadi
from Kisiler
where DogumYeri = ?;"""
parametreler = [DogumYeri.get()]
Kayitlar = cursor.execute (komut, parametreler)
select.delete(0,END)
for KisiAdi, KisiSoyadi in Kayitlar:
select.insert (END, KisiAdi + ' ' + KisiSoyadi)
connection.commit()
def Temizle():
KisiAdi.set('')
KisiSoyadi.set('')
DogumYeri.set('')
DogumTarihi.set('')
def FormOlustur():
xlabel = 30
xentry = 100
Label(root, bg="SlateGray4", text= "Kişi Adı").place(x=xlabel,y=30)
Entry(root, textvariable=KisiAdi).place(x=xentry,y=30)
Label(root,bg= "SlateGray4" ,text="Kişi Soyadı").place(x = xlabel, y= 50)
Entry(root, textvariable= KisiSoyadi).place(x = xentry, y=50)
Label(root,bg= "SlateGray4" ,text="Doğum Yeri").place(x = xlabel, y= 70)
Entry(root, textvariable= DogumYeri).place(x = xentry, y=70)
Label(root,bg= "SlateGray4" ,text="Doğum Tarihi").place(x = xlabel, y= 90)
Entry(root, textvariable= DogumTarihi).place(x = xentry, y=90)
ybutton = 120
Button(root, text="Ekle", bg="SlateGray4", command=Ekle).place(x = 100, y = ybutton)
Button (root, text="Sorgula", bg="SlateGray4", command=Sorgula).place (x=130, y=ybutton)
Button (root, text="Listele", bg="SlateGray4", command=Listele).place (x=180, y=ybutton)
Button (root, text="Güncelle", bg="SlateGray4", command=Guncelle).place (x=220, y=ybutton)
Button (root, text="Sil", bg="SlateGray4", command=Sil).place (x=270, y=ybutton)
Button (root, text="Temizle", bg="SlateGray4", command=Temizle).place (x=290, y=ybutton)
Button (root, text="Çık", bg="SlateGray4", command=Cik).place (x=350, y=ybutton)
root.mainloop()
#--------------------------------------------------------------------------------------------------------------------
FormOlustur()
connection.close ()
Yorumlar
Yorum Gönder