from tkinter import *
import pypyodbc
def giris():
username=username_entry.get()
password=password_entry.get()
login_master.destroy()
connect_str=(
'Driver={SQL Server};'
'Server=.\SQLEXPRESS;'
'Database=Telefon;'
f"UID={username};"
f"PWD={password};"
"Trusted_Connection=no"
)
db = pypyodbc.connect(connect_str)
imlec = db.cursor()
veri = imlec.execute("Select * from Telefon").fetchall() ##list yapısı içinde liste olarak döner
print(veri)
sayi = imlec.execute("SELECT COUNT(*) FROM Telefon").fetchall() ##list yapısı içinde liste olarak döner
print(sayi)
def yenile():
listbox.delete(0, END)
veri = imlec.execute("Select * from Telefon").fetchall() ##list yapısı içinde liste olarak döner
print(veri)
sayi = imlec.execute("SELECT COUNT(*) FROM Telefon").fetchall() ##list yapısı içinde liste olarak döner
print(sayi)
for i in range(sayi[0][0]):
listbox.insert(END,
f" {veri[i][0]}. {veri[i][1]}, {veri[i][2]}, {veri[i][3]}, {veri[i][4]}, {veri[i][5]}, Geliş Tarihi: {veri[i][6]}, Teslim Tarihi: {veri[i][7]}")
master = Tk()
master.geometry("800x500")
frame1 = Frame(master, bg='#add8e6').place(relheight=0.9, relwidth=0.9, relx=0.05, rely=0.05)
scroll = Scrollbar(frame1)
listbox = Listbox(frame1, yscrollcommand=scroll.set)
for i in range(sayi[0][0]):
listbox.insert(END,
f" {veri[i][0]}. {veri[i][1]}, {veri[i][2]}, {veri[i][3]}, {veri[i][4]}, {veri[i][5]}, Geliş Tarihi: {veri[i][6]}, Teslim Tarihi: {veri[i][7]}")
listbox.place(relwidth=0.8, relheight=0.7, rely=0.06, relx=0.098)
scroll.config(command=listbox.yview)
scroll.pack(side=RIGHT, fill=Y)
def goster():
gosterilen1 = listbox.selection_get()
a = gosterilen1.split(",")
print(a)
goster_master = Tk()
goster_master.geometry("600x840")
gstr_frame = Frame(goster_master, bg="#FAFAEB")
gstr_frame.place(relwidth=0.9, relheight=0.9, relx=0.05, rely=0.05)
gstr_frame1 = Frame(gstr_frame, bg="#add8e6")
gstr_frame1.place(relwidth=0.9, relheight=0.13, relx=0.05, rely=0.05)
gster_label1 = Label(gstr_frame1, bg="#FAFAEB", text=f"Marka/Mode: {a[0]}")
gster_label1.place(relwidth=0.9, relheight=0.9, relx=0.05, rely=0.05)
gstr_frame2 = Frame(gstr_frame, bg="#add8e6")
gstr_frame2.place(relwidth=0.9, relheight=0.13, relx=0.05, rely=0.2)
gster_label2 = Label(gstr_frame2, bg="#FAFAEB", text=f"Arıza Nedeni: {a[1]}")
gster_label2.place(relwidth=0.9, relheight=0.9, relx=0.05, rely=0.05)
gstr_frame3 = Frame(gstr_frame, bg="#add8e6")
gstr_frame3.place(relwidth=0.9, relheight=0.13, relx=0.05, rely=0.35)
gster_label3 = Label(gstr_frame3, bg="#FAFAEB", text=f"Yapılan İşlem: {a[2]}")
gster_label3.place(relwidth=0.9, relheight=0.9, relx=0.05, rely=0.05)
gstr_frame4 = Frame(gstr_frame, bg="#add8e6")
gstr_frame4.place(relwidth=0.9, relheight=0.13, relx=0.05, rely=0.50)
gster_label4 = Label(gstr_frame4, bg="#FAFAEB", text=f"Değişen Parça: {a[3]}")
gster_label4.place(relwidth=0.9, relheight=0.9, relx=0.05, rely=0.05)
gstr_frame5 = Frame(gstr_frame, bg="#add8e6")
gstr_frame5.place(relwidth=0.9, relheight=0.13, relx=0.05, rely=0.65)
gster_label5 = Label(gstr_frame5, bg="#FAFAEB", text=f"İsim/Soyisim: {a[4]}")
gster_label5.place(relwidth=0.9, relheight=0.9, relx=0.05, rely=0.05)
gstr_frame6 = Frame(gstr_frame, bg="#add8e6")
gstr_frame6.place(relwidth=0.9, relheight=0.13, relx=0.05, rely=0.80)
gster_label61 = Label(gstr_frame6, bg="#FAFAEB", text=f"Geliş Tarihi: {a[5]}")
gster_label61.place(relwidth=0.45, relheight=0.9, relx=0.01, rely=0.05)
gster_label62 = Label(gstr_frame6, bg="#FAFAEB", text=f"Teslim Tarihi: {a[6]}")
gster_label62.place(relwidth=0.45, relheight=0.9, relx=0.54, rely=0.05)
goster_master.mainloop()
Button(frame1, text="Yenile", height=4, width=15,command=yenile).place(relx=0.3, rely=0.8)
Button(frame1, text="Göster", height=4, width=15, command=goster).place(relx=0.5, rely=0.8)
master.mainloop()
login_master=Tk()
login_master.geometry("400x200")
login_frame=Frame(login_master,bg="#FFFD86")
login_frame.place(relheight=0.9,relwidth=0.9,relx=0.05,rely=0.05)
username_label2=Label(login_frame,text="Kullanıcı Adı:",bg="#FFFD86")
username_label2.place(relwidth=0.22,rely=0.12,relx=0.15)
username_entry=Entry(login_frame)
username_entry.place(relwidth=0.5,rely=0.12,relx=0.4)
password_label3=Label(login_frame,text="Şifre:",bg="#FFFD86")
password_label3.place(relwidth=0.15,rely=0.35,relx=0.25)
password_entry=Entry(login_frame)
password_entry.place(relwidth=0.5,rely=0.35,relx=0.4)
save_login_button=Button(login_frame,text="Giriş",command=giris)
save_login_button.place(relheight=0.15,relwidth=0.3,rely=0.6,relx=0.6)
login_master.mainloop()
username_entry=Entry(login_frame)
username_entry.place(relwidth=0.5,rely=0.12,relx=0.4)
password_entry=Entry(login_frame)
password_entry.place(relwidth=0.5,rely=0.35,relx=0.4)
bu entrylerden aldığım değerleri giriş fonksiyonunda kullanamıyorum kulllanıcı adını ve şifreyi yanlış girsem ya da hiç girmesem de butona tıkladığımda veri tabanına giriş yapabiliyorum ama böyle olmaması gerekiyor burada sorun nedir?