Çözüldü Kod nasıl EXE'ye dönüştürülür?

Bu konu çözüldü olarak işaretlenmiştir. Çözülmediğini düşünüyorsanız konuyu rapor edebilirsiniz.

Error 01

Hectopat
Katılım
8 Nisan 2021
Mesajlar
204
Daha fazla  
Cinsiyet
Erkek
Bir kod yazdım bunu EXE'ye çevirmek için ChatGPT bir şeyler yaptırdı ama olmadı. Ne yapacağım? İsterseniz kodu atabilirim.
 
Son düzenleyen: Moderatör:
Çözüm
Pyinstaller ile EXE'ye çevirirken hata almanız doğal çünkü DateEntry bileşeniyle ttkbootstrap arasında uyumsuzluk var. from tkcalendar import DateEntry satırını from ttkbootstrap.widgets import DateEntry olarak güncelledim. Ayrıca date_pattern="yyyy-mm-dd" parametresini kaldırdım ve entry_bit.delete(0, tk.END) satırını sildim (yeni DateEntry sınıfı delete metodunu desteklemiyor).

Kodun güncel hali:

Python:
import tkinter as tk
from tkinter import messagebox
from tkinter import ttk
from ttkbootstrap import Style, Window
import json
import os
from datetime import datetime
from ttkbootstrap.widgets import DateEntry
import uuid

# Faiz hesaplama fonksiyonları
def gunluk_bilesik_faiz(anapara, gun_sayisi, yillik_faiz_orani):
    oran = (yillik_faiz_orani / 100) / 365
    toplam = anapara * (1 + oran) ** gun_sayisi
    return toplam - anapara, toplam

def tarih_farki(baslangic, bitis):
    bas = datetime.strptime(baslangic, "%Y-%m-%d")
    bit = datetime.strptime(bitis, "%Y-%m-%d")
    return (bit - bas).days

def musteri_hesapla(anapara, faiz, bas_tarih, bit_tarih):
    fark = tarih_farki(bas_tarih, bit_tarih)
    if fark < 0:
        return None, "Tarih hatalı"
    getiri, toplam = gunluk_bilesik_faiz(anapara, fark, faiz)
    return {"gun": fark, "getiri": getiri, "toplam": toplam}, None

def musterileri_yukle():
    if not os.path.exists("musteriler.json"):
        return []
    try:
        with open("musteriler.json", "r", encoding="utf-8") as f:
            return json.load(f)
    except Exception as e:
        messagebox.showerror("Hata", f"Veri yüklenemedi: {e}")
        return []

def kaydet(isim, anapara, faiz, bas_tarih, bit_tarih):
    try:
        data = musterileri_yukle()
        sonuc, hata = musteri_hesapla(anapara, faiz, bas_tarih, bit_tarih or datetime.now().strftime("%Y-%m-%d"))
        if hata:
            return None, hata

        musteri = {
            "ID": str(uuid.uuid4()),
            "İsim": isim,
            "Anapara": anapara,
            "Faiz": faiz,
            "Başlangıç": bas_tarih,
            "Bitiş": bit_tarih or datetime.now().strftime("%Y-%m-%d"),
            "Gün": sonuc["gun"],
            "Getiri": round(sonuc["getiri"], 2),
            "Toplam": round(sonuc["toplam"], 2)
        }
        data.append(musteri)
        with open("musteriler.json", "w", encoding="utf-8") as f:
            json.dump(data, f, ensure_ascii=False, indent=4)
        return True, None
    except Exception as e:
        return None, str(e)

# GUI Başlat
root = Window(themename="darkly")
root.title("AĞCA TARIM")
root.geometry("1000x700")
style = Style()

# Stil tanımı
style.configure("TLabel", font=("Roboto", 12))
style.configure("TButton", font=("Roboto", 12, "bold"))

# Başlık
ttk.Label(root, text="AĞCA TARIM", font=("Roboto", 28, "bold"), foreground="#00BFFF", background="#1C2526").pack(pady=20)

main_frame = ttk.Frame(root)
main_frame.pack(fill="both", expand=True, padx=20, pady=10)

form = ttk.Frame(main_frame)
form.pack(pady=20)

ttk.Label(form, text="Müşteri İsmi:").grid(row=0, column=0, sticky="e", pady=5)
entry_isim = ttk.Entry(form)
entry_isim.grid(row=0, column=1, padx=10)

ttk.Label(form, text="Anapara (TL):").grid(row=1, column=0, sticky="e", pady=5)
entry_anapara = ttk.Entry(form)
entry_anapara.grid(row=1, column=1, padx=10)

ttk.Label(form, text="Yıllık Faiz (%):").grid(row=2, column=0, sticky="e", pady=5)
entry_faiz = ttk.Entry(form)
entry_faiz.grid(row=2, column=1, padx=10)

ttk.Label(form, text="Başlangıç Tarihi:").grid(row=3, column=0, sticky="e", pady=5)
entry_bas = DateEntry(form, dateformat="%Y-%m-%d")
entry_bas.grid(row=3, column=1, padx=10)

ttk.Label(form, text="Bitiş Tarihi (Ops.):").grid(row=4, column=0, sticky="e", pady=5)
entry_bit = DateEntry(form, dateformat="%Y-%m-%d")
entry_bit.grid(row=4, column=1, padx=10)

# Liste Alanı
liste_frame = ttk.Frame(main_frame)
tree = ttk.Treeview(liste_frame, columns=("İsim", "Anapara", "Faiz", "Başlangıç", "Bitiş", "Gün", "Getiri", "Toplam"), show="headings")
for col in tree["columns"]:
    tree.heading(col, text=col)
    tree.column(col, width=120)
tree.pack(fill="both", expand=True)
scroll = ttk.Scrollbar(liste_frame, orient="vertical", command=tree.yview)
tree.configure(yscrollcommand=scroll.set)
scroll.pack(side="right", fill="y")

# Fonksiyonlar
def musteri_ekle():
    try:
        isim = entry_isim.get()
        anapara = float(entry_anapara.get())
        faiz = float(entry_faiz.get())
        bas = entry_bas.entry.get()
        bit = entry_bit.entry.get() or None
        if not isim:
            messagebox.showerror("Hata", "İsim gerekli")
            return
        ok, hata = kaydet(isim, anapara, faiz, bas, bit)
        if hata:
            messagebox.showerror("Hata", hata)
            return
        messagebox.showinfo("Başarılı", "Müşteri eklendi")
        entry_isim.delete(0, tk.END)
        entry_anapara.delete(0, tk.END)
        entry_faiz.delete(0, tk.END)
        entry_bit.entry.delete(0, tk.END)
        musteri_listele()
    except ValueError:
        messagebox.showerror("Hata", "Geçersiz değer girdiniz")

def musteri_listele():
    tree.delete(*tree.get_children())
    for m in musterileri_yukle():
        tree.insert("", tk.END, values=(m["İsim"], m["Anapara"], m["Faiz"], m["Başlangıç"], m["Bitiş"], m["Gün"], m["Getiri"], m["Toplam"]))

# Butonlar
btn_frame = ttk.Frame(root)
btn_frame.pack(pady=10)
ttk.Button(btn_frame, text="Ekle", command=musteri_ekle).pack(side="left", padx=5)
ttk.Button(btn_frame, text="Listele", command=musteri_listele).pack(side="left", padx=5)

liste_frame.pack(fill="both", expand=True, padx=10, pady=10)

musteri_listele()
root.mainloop()

PyInstaller ile EXE'ye çevrilmiş halinin indirme linki: Dropbox
Kodu yazdığınız ortam Visual Studio ve .NET ise derleyip exe olarak Publish edebilirsiniz. Kodu atarsanız ekran görüntüsü olarak yardımcı olabilirim.
Python:
import tkinter as tk
from tkinter import messagebox
from ttkbootstrap import Style, Window, ttk
import json
import os
from datetime import datetime
from tkcalendar import DateEntry
import uuid


# Günlük bileşik faiz hesaplama
def gunluk_bilesik_faiz(anapara, gun_sayisi, yillik_faiz_orani):
    gunluk_faiz_orani = (yillik_faiz_orani / 100) / 365
    toplam = anapara * (1 + gunluk_faiz_orani) ** gun_sayisi
    faiz_getirisi = toplam - anapara
    return faiz_getirisi, toplam


# Tarih farkı hesaplama
def tarih_farki_hesapla(baslangic_tarihi, bitis_tarihi):
    baslangic = datetime.strptime(baslangic_tarihi, "%Y-%m-%d")
    bitis = datetime.strptime(bitis_tarihi, "%Y-%m-%d")
    return (bitis - baslangic).days


# Müşteri hesaplama
def musteri_hesaplama(anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi):
    gun_farki = tarih_farki_hesapla(baslangic_tarihi, bitis_tarihi)
    if gun_farki < 0:
        return None, "Hata: Başlangıç tarihi bitiş tarihinden sonra olamaz!"
  
    faiz_getirisi, toplam = gunluk_bilesik_faiz(anapara, gun_farki, yillik_faiz_orani)
    return {
        "gun_sayisi": gun_farki,
        "faiz_getirisi": faiz_getirisi,
        "toplam": toplam
    }, None


# Müşterileri JSON’a kaydetme
def kaydet_sonuclar(isim, anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi):
    dosya_adi = "musteriler.json"
    hesaplama_id = str(uuid.uuid4())
  
    try:
        musteriler = musterileri_yukle()
        sonuc, hata = musteri_hesaplama(anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi or datetime.now().strftime("%Y-%m-%d"))
        if hata:
            return None, hata
      
        musteri = {
            "Hesaplama ID": hesaplama_id,
            "Müşteri İsmi": isim,
            "Anapara (TL)": anapara,
            "Yıllık Faiz (%)": yillik_faiz_orani,
            "Başlangıç Tarihi": baslangic_tarihi,
            "Bitiş Tarihi": bitis_tarihi or datetime.now().strftime("%Y-%m-%d"),
            "Gün Sayısı": sonuc["gun_sayisi"],
            "Faiz Getirisi (TL)": round(sonuc["faiz_getirisi"], 2),
            "Toplam (TL)": round(sonuc["toplam"], 2)
        }
        musteriler.append(musteri)
      
        with open(dosya_adi, "w", encoding="utf-8") as f:
            json.dump(musteriler, f, ensure_ascii=False, indent=4)
        return dosya_adi, None
  
    except Exception as e:
        return None, f"Veri kaydetme başarısız: {str(e)}"


# Müşterileri JSON’dan yükleme
def musterileri_yukle():
    dosya_adi = "musteriler.json"
    if not os.path.exists(dosya_adi):
        return []
  
    try:
        with open(dosya_adi, "r", encoding="utf-8") as f:
            return json.load(f)
    except Exception as e:
        messagebox.showerror("Hata", f"Veri yükleme başarısız: {str(e)}")
        return []


# Ana uygulama
root = Window(themename="darkly")
root.title("AĞCA TARIM")
root.geometry("1000x700")
root.resizable(True, True)


# Stil ayarları
style = Style()
style.configure("TButton", font=("Roboto", 12, "bold"), padding=10, background="#00BFFF", foreground="black")
style.configure("TLabel", font=("Roboto", 12), foreground="#00FF00")
style.configure("TEntry", font=("Roboto", 12), background="#2C2C2C", foreground="white")
style.configure("TFrame", background="#1C2526")


# Başlık
title_label = ttk.Label(root, text="AĞCA TARIM", font=("Roboto", 28, "bold"), foreground="#00BFFF", background="#1C2526")
title_label.pack(pady=20)


# Ana çerçeve
main_frame = ttk.Frame(root, style="TFrame")
main_frame.pack(pady=10, padx=20, fill="both", expand=True)


# Müşteri ekleme çerçevesi
ekleme_frame = ttk.Frame(main_frame, style="TFrame")
form_frame = ttk.Frame(ekleme_frame, style="TFrame")
form_frame.pack(pady=20)


ttk.Label(form_frame, text="Yeni Müşteri Ekle", font=("Roboto", 16, "bold"), foreground="#00FF00").grid(row=0, column=0, columnspan=2, pady=10)
ttk.Label(form_frame, text="Müşteri İsmi:").grid(row=1, column=0, padx=10, pady=5, sticky="e")
entry_isim = ttk.Entry(form_frame, width=30)
entry_isim.grid(row=1, column=1, padx=10, pady=5)


ttk.Label(form_frame, text="Anapara (TL):").grid(row=2, column=0, padx=10, pady=5, sticky="e")
entry_anapara = ttk.Entry(form_frame, width=30)
entry_anapara.grid(row=2, column=1, padx=10, pady=5)


ttk.Label(form_frame, text="Yıllık Faiz (%):").grid(row=3, column=0, padx=10, pady=5, sticky="e")
entry_faiz = ttk.Entry(form_frame, width=30)
entry_faiz.grid(row=3, column=1, padx=10, pady=5)


ttk.Label(form_frame, text="Başlangıç Tarihi:").grid(row=4, column=0, padx=10, pady=5, sticky="e")
entry_baslangic = DateEntry(form_frame, width=27, date_pattern="yyyy-mm-dd")
entry_baslangic.grid(row=4, column=1, padx=10, pady=5)


ttk.Label(form_frame, text="Bitiş Tarihi (Opsiyonel):").grid(row=5, column=0, padx=10, pady=5, sticky="e")
entry_bitis = DateEntry(form_frame, width=27, date_pattern="yyyy-mm-dd")
entry_bitis.grid(row=5, column=1, padx=10, pady=5)
entry_bitis.delete(0, tk.END)


# Müşteri listesi çerçevesi
list_frame = ttk.Frame(main_frame, style="TFrame")
ttk.Label(list_frame, text="Müşteri Listesi", font=("Roboto", 16, "bold"), foreground="#00FF00").pack(pady=10)


tree_musteriler = ttk.Treeview(list_frame, columns=("İsim", "Anapara", "Faiz", "Başlangıç", "Bitiş", "Gün", "Getiri", "Toplam"), show="headings")
tree_musteriler.heading("İsim", text="Müşteri İsmi")
tree_musteriler.heading("Anapara", text="Anapara (TL)")
tree_musteriler.heading("Faiz", text="Yıllık Faiz (%)")
tree_musteriler.heading("Başlangıç", text="Başlangıç Tarihi")
tree_musteriler.heading("Bitiş", text="Bitiş Tarihi")
tree_musteriler.heading("Gün", text="Gün Sayısı")
tree_musteriler.heading("Getiri", text="Faiz Getirisi (TL)")
tree_musteriler.heading("Toplam", text="Toplam (TL)")
tree_musteriler.column("İsim", width=150)
tree_musteriler.column("Anapara", width=100)
tree_musteriler.column("Faiz", width=100)
tree_musteriler.column("Başlangıç", width=100)
tree_musteriler.column("Bitiş", width=100)
tree_musteriler.column("Gün", width=80)
tree_musteriler.column("Getiri", width=120)
tree_musteriler.column("Toplam", width=120)
tree_musteriler.pack(pady=10, fill="both", expand=True)


scrollbar = ttk.Scrollbar(list_frame, orient="vertical", command=tree_musteriler.yview)
scrollbar.pack(side="right", fill="y")
tree_musteriler.configure(yscrollcommand=scrollbar.set)


# Mod geçişleri
def goster_ekleme_modu():
    list_frame.pack_forget()
    ekleme_frame.pack(fill="both", expand=True)
    ekle_btn.pack()
    guncelle_btn.pack_forget()
    musteri_listesi_btn.pack()


def goster_liste_modu():
    ekleme_frame.pack_forget()
    list_frame.pack(fill="both", expand=True)


# Yeni müşteri ekleme
def yeni_musteri_ekle():
    try:
        isim = entry_isim.get().strip()
        anapara = float(entry_anapara.get())
        yillik_faiz_orani = float(entry_faiz.get())
        baslangic_tarihi = entry_baslangic.get_date().strftime("%Y-%m-%d")
        bitis_tarihi = entry_bitis.get() if entry_bitis.get() else None
      
        if not isim:
            messagebox.showerror("Hata", "Lütfen müşteri ismi girin!")
            return
        if anapara <= 0 or yillik_faiz_orani <= 0:
            messagebox.showerror("Hata", "Anapara ve faiz oranı pozitif olmalıdır!")
            return
      
        dosya_adi, hata = kaydet_sonuclar(isim, anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi)
        if hata:
            messagebox.showerror("Hata", hata)
            return
      
        messagebox.showinfo("Başarılı", f"Müşteri {isim} eklendi!")
        entry_isim.delete(0, tk.END)
        entry_anapara.delete(0, tk.END)
        entry_faiz.delete(0, tk.END)
        entry_bitis.delete(0, tk.END)
        goster_liste_modu()
        musterileri_guncelle()
  
    except ValueError:
        messagebox.showerror("Hata", "Lütfen geçerli sayısal değerler girin!")


# Müşterileri güncelleme
def musterileri_guncelle():
    for item in tree_musteriler.get_children():
        tree_musteriler.delete(item)
  
    musteriler = musterileri_yukle()
    bugun = datetime.now().strftime("%Y-%m-%d")
    for musteri in musteriler:
        bitis_tarihi = musteri["Bitiş Tarihi"] if musteri["Bitiş Tarihi"] else bugun
        sonuc, hata = musteri_hesaplama(
            musteri["Anapara (TL)"],
            musteri["Yıllık Faiz (%)"],
            musteri["Başlangıç Tarihi"],
            bitis_tarihi
        )
        if not hata:
            tree_musteriler.insert("", tk.END, values=(
                musteri["Müşteri İsmi"],
                musteri["Anapara (TL)"],
                musteri["Yıllık Faiz (%)"],
                musteri["Başlangıç Tarihi"],
                bitis_tarihi,
                sonuc["gun_sayisi"],
                f"{sonuc['faiz_getirisi']:.2f}",
                f"{sonuc['toplam']:.2f}"
            ))


# Silme
def sil_musteri():
    selected_item = tree_musteriler.selection()
    if not selected_item:
        messagebox.showwarning("Uyarı", "Lütfen silmek için bir müşteri seçin!")
        return
  
    if not messagebox.askyesno("Onay", "Seçilen müşteri kaydını silmek istediğinize emin misiniz?"):
        return
  
    selected_values = tree_musteriler.item(selected_item)["values"]
    musteriler = musterileri_yukle()
    musteriler = [m for m in musteriler if not (m["Müşteri İsmi"] == selected_values[0] and m["Başlangıç Tarihi"] == selected_values[3])]
  
    try:
        with open("musteriler.json", "w", encoding="utf-8") as f:
            json.dump(musteriler, f, ensure_ascii=False, indent=4)
        musterileri_guncelle()
        messagebox.showinfo("Başarılı", "Müşteri kaydı silindi!")
    except Exception as e:
        messagebox.showerror("Hata", f"Silme işlemi başarısız: {str(e)}")


# Düzenleme
def duzenle_musteri():
    selected_item = tree_musteriler.selection()
    if not selected_item:
        messagebox.showwarning("Uyarı", "Lütfen düzenlemek için bir müşteri seçin!")
        return
  
    selected_values = tree_musteriler.item(selected_item)["values"]
    entry_isim.delete(0, tk.END)
    entry_isim.insert(0, selected_values[0])
    entry_anapara.delete(0, tk.END)
    entry_anapara.insert(0, selected_values[1])
    entry_faiz.delete(0, tk.END)
    entry_faiz.insert(0, selected_values[2])
    entry_baslangic.set_date(selected_values[3])
    entry_bitis.delete(0, tk.END)
    if selected_values[4] != datetime.now().strftime("%Y-%m-%d"):
        entry_bitis.set_date(selected_values[4])
  
    goster_ekleme_modu()
    ekle_btn.pack_forget()
    guncelle_btn.pack()


# Güncelleme
def guncelle_musteri():
    try:
        isim = entry_isim.get().strip()
        anapara = float(entry_anapara.get())
        yillik_faiz_orani = float(entry_faiz.get())
        baslangic_tarihi = entry_baslangic.get_date().strftime("%Y-%m-%d")
        bitis_tarihi = entry_bitis.get() if entry_bitis.get() else None
      
        if not isim:
            messagebox.showerror("Hata", "Lütfen müşteri ismi girin!")
            return
        if anapara <= 0 or yillik_faiz_orani <= 0:
            messagebox.showerror("Hata", "Anapara ve faiz oranı pozitif olmalıdır!")
            return
      
        selected_item = tree_musteriler.selection()
        selected_values = tree_musteriler.item(selected_item)["values"]
      
        musteriler = musterileri_yukle()
        for musteri in musteriler:
            if musteri["Müşteri İsmi"] == selected_values[0] and musteri["Başlangıç Tarihi"] == selected_values[3]:
                sonuc, hata = musteri_hesaplama(anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi or datetime.now().strftime("%Y-%m-%d"))
                if hata:
                    messagebox.showerror("Hata", hata)
                    return
                musteri.update({
                    "Müşteri İsmi": isim,
                    "Anapara (TL)": anapara,
                    "Yıllık Faiz (%)": yillik_faiz_orani,
                    "Başlangıç Tarihi": baslangic_tarihi,
                    "Bitiş Tarihi": bitis_tarihi or datetime.now().strftime("%Y-%m-%d"),
                    "Gün Sayısı": sonuc["gun_sayisi"],
                    "Faiz Getirisi (TL)": round(sonuc["faiz_getirisi"], 2),
                    "Toplam (TL)": round(sonuc["toplam"], 2)
                })
                break
      
        with open("musteriler.json", "w", encoding="utf-8") as f:
            json.dump(musteriler, f, ensure_ascii=False, indent=4)
      
        messagebox.showinfo("Başarılı", "Müşteri bilgileri güncellendi!")
        entry_isim.delete(0, tk.END)
        entry_anapara.delete(0, tk.END)
        entry_faiz.delete(0, tk.END)
        entry_bitis.delete(0, tk.END)
        goster_liste_modu()
        musterileri_guncelle()
  
    except ValueError:
        messagebox.showerror("Hata", "Lütfen geçerli sayısal değerler girin!")
    except Exception as e:
        messagebox.showerror("Hata", f"Güncelleme başarısız: {str(e)}")


# Butonlar
ekle_btn = ttk.Button(form_frame, text="Müşteri Ekle", command=yeni_musteri_ekle, style="TButton")
ekle_btn.grid(row=6, column=0, columnspan=2, pady=20)


guncelle_btn = ttk.Button(form_frame, text="Güncelle", command=guncelle_musteri, style="TButton")
musteri_listesi_btn = ttk.Button(form_frame, text="Müşterileri Gör", command=goster_liste_modu, style="TButton")
musteri_listesi_btn.grid(row=7, column=0, columnspan=2, pady=10)


btn_frame = ttk.Frame(list_frame, style="TFrame")
btn_frame.pack(pady=10)
ttk.Button(btn_frame, text="Yeni Müşteri Ekle", command=goster_ekleme_modu, style="TButton").pack(side="left", padx=5)
ttk.Button(btn_frame, text="Sil", command=sil_musteri, style="TButton").pack(side="left", padx=5)
ttk.Button(btn_frame, text="Düzenle", command=duzenle_musteri, style="TButton").pack(side="left", padx=5)


# Varsayılan: Liste modu
goster_liste_modu()
musterileri_guncelle()


root.mainloop()
 
Son düzenleyen: Moderatör:
import tkinter as tk
from tkinter import messagebox
from ttkbootstrap import Style, Window, ttk
import json
import os
from datetime import datetime
from tkcalendar import DateEntry
import uuid

# Günlük bileşik faiz hesaplama
def gunluk_bilesik_faiz(anapara, gun_sayisi, yillik_faiz_orani):
gunluk_faiz_orani = (yillik_faiz_orani / 100) / 365
toplam = anapara * (1 + gunluk_faiz_orani) ** gun_sayisi
faiz_getirisi = toplam - anapara
return faiz_getirisi, toplam

# Tarih farkı hesaplama
def tarih_farki_hesapla(baslangic_tarihi, bitis_tarihi):
baslangic = datetime.strptime(baslangic_tarihi, "%Y-%m-%d")
bitis = datetime.strptime(bitis_tarihi, "%Y-%m-%d")
return (bitis - baslangic).days

# Müşteri hesaplama
def musteri_hesaplama(anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi):
gun_farki = tarih_farki_hesapla(baslangic_tarihi, bitis_tarihi)
if gun_farki < 0:
return None, "Hata: Başlangıç tarihi bitiş tarihinden sonra olamaz!"

faiz_getirisi, toplam = gunluk_bilesik_faiz(anapara, gun_farki, yillik_faiz_orani)
return {
"gun_sayisi": gun_farki,
"faiz_getirisi": faiz_getirisi,
"toplam": toplam
}, None

# Müşterileri JSON’a kaydetme
def kaydet_sonuclar(isim, anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi):
dosya_adi = "musteriler.json"
hesaplama_id = str(uuid.uuid4())

try:
musteriler = musterileri_yukle()
sonuc, hata = musteri_hesaplama(anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi or datetime.now().strftime("%Y-%m-%d"))
if hata:
return None, hata

musteri = {
"Hesaplama ID": hesaplama_id,
"Müşteri İsmi": isim,
"Anapara (TL)": anapara,
"Yıllık Faiz (%)": yillik_faiz_orani,
"Başlangıç Tarihi": baslangic_tarihi,
"Bitiş Tarihi": bitis_tarihi or datetime.now().strftime("%Y-%m-%d"),
"Gün Sayısı": sonuc["gun_sayisi"],
"Faiz Getirisi (TL)": round(sonuc["faiz_getirisi"], 2),
"Toplam (TL)": round(sonuc["toplam"], 2)
}
musteriler.append(musteri)

with open(dosya_adi, "w", encoding="utf-8") as f:
json.dump(musteriler, f, ensure_ascii=False, indent=4)
return dosya_adi, None

except Exception as e:
return None, f"Veri kaydetme başarısız: {str(e)}"

# Müşterileri JSON’dan yükleme
def musterileri_yukle():
dosya_adi = "musteriler.json"
if not os.path.exists(dosya_adi):
return []

try:
with open(dosya_adi, "r", encoding="utf-8") as f:
return json.load(f)
except Exception as e:
messagebox.showerror("Hata", f"Veri yükleme başarısız: {str(e)}")
return []

# Ana uygulama
root = Window(themename="darkly")
root.title("AĞCA TARIM")
root.geometry("1000x700")
root.resizable(True, True)

# Stil ayarları
style = Style()
style.configure("TButton", font=("Roboto", 12, "bold"), padding=10, background="#00BFFF", foreground="black")
style.configure("TLabel", font=("Roboto", 12), foreground="#00FF00")
style.configure("TEntry", font=("Roboto", 12), background="#2C2C2C", foreground="white")
style.configure("TFrame", background="#1C2526")

# Başlık
title_label = ttk.Label(root, text="AĞCA TARIM", font=("Roboto", 28, "bold"), foreground="#00BFFF", background="#1C2526")
title_label.pack(pady=20)

# Ana çerçeve
main_frame = ttk.Frame(root, style="TFrame")
main_frame.pack(pady=10, padx=20, fill="both", expand=True)

# Müşteri ekleme çerçevesi
ekleme_frame = ttk.Frame(main_frame, style="TFrame")
form_frame = ttk.Frame(ekleme_frame, style="TFrame")
form_frame.pack(pady=20)

ttk.Label(form_frame, text="Yeni Müşteri Ekle", font=("Roboto", 16, "bold"), foreground="#00FF00").grid(row=0, column=0, columnspan=2, pady=10)
ttk.Label(form_frame, text="Müşteri İsmi:").grid(row=1, column=0, padx=10, pady=5, sticky="e")
entry_isim = ttk.Entry(form_frame, width=30)
entry_isim.grid(row=1, column=1, padx=10, pady=5)

ttk.Label(form_frame, text="Anapara (TL):").grid(row=2, column=0, padx=10, pady=5, sticky="e")
entry_anapara = ttk.Entry(form_frame, width=30)
entry_anapara.grid(row=2, column=1, padx=10, pady=5)

ttk.Label(form_frame, text="Yıllık Faiz (%):").grid(row=3, column=0, padx=10, pady=5, sticky="e")
entry_faiz = ttk.Entry(form_frame, width=30)
entry_faiz.grid(row=3, column=1, padx=10, pady=5)

ttk.Label(form_frame, text="Başlangıç Tarihi:").grid(row=4, column=0, padx=10, pady=5, sticky="e")
entry_baslangic = DateEntry(form_frame, width=27, date_pattern="yyyy-mm-dd")
entry_baslangic.grid(row=4, column=1, padx=10, pady=5)

ttk.Label(form_frame, text="Bitiş Tarihi (Opsiyonel):").grid(row=5, column=0, padx=10, pady=5, sticky="e")
entry_bitis = DateEntry(form_frame, width=27, date_pattern="yyyy-mm-dd")
entry_bitis.grid(row=5, column=1, padx=10, pady=5)
entry_bitis.delete(0, tk.END)

# Müşteri listesi çerçevesi
list_frame = ttk.Frame(main_frame, style="TFrame")
ttk.Label(list_frame, text="Müşteri Listesi", font=("Roboto", 16, "bold"), foreground="#00FF00").pack(pady=10)

tree_musteriler = ttk.Treeview(list_frame, columns=("İsim", "Anapara", "Faiz", "Başlangıç", "Bitiş", "Gün", "Getiri", "Toplam"), show="headings")
tree_musteriler.heading("İsim", text="Müşteri İsmi")
tree_musteriler.heading("Anapara", text="Anapara (TL)")
tree_musteriler.heading("Faiz", text="Yıllık Faiz (%)")
tree_musteriler.heading("Başlangıç", text="Başlangıç Tarihi")
tree_musteriler.heading("Bitiş", text="Bitiş Tarihi")
tree_musteriler.heading("Gün", text="Gün Sayısı")
tree_musteriler.heading("Getiri", text="Faiz Getirisi (TL)")
tree_musteriler.heading("Toplam", text="Toplam (TL)")
tree_musteriler.column("İsim", width=150)
tree_musteriler.column("Anapara", width=100)
tree_musteriler.column("Faiz", width=100)
tree_musteriler.column("Başlangıç", width=100)
tree_musteriler.column("Bitiş", width=100)
tree_musteriler.column("Gün", width=80)
tree_musteriler.column("Getiri", width=120)
tree_musteriler.column("Toplam", width=120)
tree_musteriler.pack(pady=10, fill="both", expand=True)

scrollbar = ttk.Scrollbar(list_frame, orient="vertical", command=tree_musteriler.yview)
scrollbar.pack(side="right", fill="y")
tree_musteriler.configure(yscrollcommand=scrollbar.set)

# Mod geçişleri
def goster_ekleme_modu():
list_frame.pack_forget()
ekleme_frame.pack(fill="both", expand=True)
ekle_btn.pack()
guncelle_btn.pack_forget()
musteri_listesi_btn.pack()

def goster_liste_modu():
ekleme_frame.pack_forget()
list_frame.pack(fill="both", expand=True)

# Yeni müşteri ekleme
def yeni_musteri_ekle():
try:
isim = entry_isim.get().strip()
anapara = float(entry_anapara.get())
yillik_faiz_orani = float(entry_faiz.get())
baslangic_tarihi = entry_baslangic.get_date().strftime("%Y-%m-%d")
bitis_tarihi = entry_bitis.get() if entry_bitis.get() else None

if not isim:
messagebox.showerror("Hata", "Lütfen müşteri ismi girin!")
return
if anapara <= 0 or yillik_faiz_orani <= 0:
messagebox.showerror("Hata", "Anapara ve faiz oranı pozitif olmalıdır!")
return

dosya_adi, hata = kaydet_sonuclar(isim, anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi)
if hata:
messagebox.showerror("Hata", hata)
return

messagebox.showinfo("Başarılı", f"Müşteri {isim} eklendi!")
entry_isim.delete(0, tk.END)
entry_anapara.delete(0, tk.END)
entry_faiz.delete(0, tk.END)
entry_bitis.delete(0, tk.END)
goster_liste_modu()
musterileri_guncelle()

except ValueError:
messagebox.showerror("Hata", "Lütfen geçerli sayısal değerler girin!")

# Müşterileri güncelleme
def musterileri_guncelle():
for item in tree_musteriler.get_children():
tree_musteriler.delete(item)

musteriler = musterileri_yukle()
bugun = datetime.now().strftime("%Y-%m-%d")
for musteri in musteriler:
bitis_tarihi = musteri["Bitiş Tarihi"] if musteri["Bitiş Tarihi"] else bugun
sonuc, hata = musteri_hesaplama(
musteri["Anapara (TL)"],
musteri["Yıllık Faiz (%)"],
musteri["Başlangıç Tarihi"],
bitis_tarihi
)
if not hata:
tree_musteriler.insert("", tk.END, values=(
musteri["Müşteri İsmi"],
musteri["Anapara (TL)"],
musteri["Yıllık Faiz (%)"],
musteri["Başlangıç Tarihi"],
bitis_tarihi,
sonuc["gun_sayisi"],
f"{sonuc['faiz_getirisi']:.2f}",
f"{sonuc['toplam']:.2f}"
))

# Silme
def sil_musteri():
selected_item = tree_musteriler.selection()
if not selected_item:
messagebox.showwarning("Uyarı", "Lütfen silmek için bir müşteri seçin!")
return

if not messagebox.askyesno("Onay", "Seçilen müşteri kaydını silmek istediğinize emin misiniz?"):
return

selected_values = tree_musteriler.item(selected_item)["values"]
musteriler = musterileri_yukle()
musteriler = [m for m in musteriler if not (m["Müşteri İsmi"] == selected_values[0] and m["Başlangıç Tarihi"] == selected_values[3])]

try:
with open("musteriler.json", "w", encoding="utf-8") as f:
json.dump(musteriler, f, ensure_ascii=False, indent=4)
musterileri_guncelle()
messagebox.showinfo("Başarılı", "Müşteri kaydı silindi!")
except Exception as e:
messagebox.showerror("Hata", f"Silme işlemi başarısız: {str(e)}")

# Düzenleme
def duzenle_musteri():
selected_item = tree_musteriler.selection()
if not selected_item:
messagebox.showwarning("Uyarı", "Lütfen düzenlemek için bir müşteri seçin!")
return

selected_values = tree_musteriler.item(selected_item)["values"]
entry_isim.delete(0, tk.END)
entry_isim.insert(0, selected_values[0])
entry_anapara.delete(0, tk.END)
entry_anapara.insert(0, selected_values[1])
entry_faiz.delete(0, tk.END)
entry_faiz.insert(0, selected_values[2])
entry_baslangic.set_date(selected_values[3])
entry_bitis.delete(0, tk.END)
if selected_values[4] != datetime.now().strftime("%Y-%m-%d"):
entry_bitis.set_date(selected_values[4])

goster_ekleme_modu()
ekle_btn.pack_forget()
guncelle_btn.pack()

# Güncelleme
def guncelle_musteri():
try:
isim = entry_isim.get().strip()
anapara = float(entry_anapara.get())
yillik_faiz_orani = float(entry_faiz.get())
baslangic_tarihi = entry_baslangic.get_date().strftime("%Y-%m-%d")
bitis_tarihi = entry_bitis.get() if entry_bitis.get() else None

if not isim:
messagebox.showerror("Hata", "Lütfen müşteri ismi girin!")
return
if anapara <= 0 or yillik_faiz_orani <= 0:
messagebox.showerror("Hata", "Anapara ve faiz oranı pozitif olmalıdır!")
return

selected_item = tree_musteriler.selection()
selected_values = tree_musteriler.item(selected_item)["values"]

musteriler = musterileri_yukle()
for musteri in musteriler:
if musteri["Müşteri İsmi"] == selected_values[0] and musteri["Başlangıç Tarihi"] == selected_values[3]:
sonuc, hata = musteri_hesaplama(anapara, yillik_faiz_orani, baslangic_tarihi, bitis_tarihi or datetime.now().strftime("%Y-%m-%d"))
if hata:
messagebox.showerror("Hata", hata)
return
musteri.update({
"Müşteri İsmi": isim,
"Anapara (TL)": anapara,
"Yıllık Faiz (%)": yillik_faiz_orani,
"Başlangıç Tarihi": baslangic_tarihi,
"Bitiş Tarihi": bitis_tarihi or datetime.now().strftime("%Y-%m-%d"),
"Gün Sayısı": sonuc["gun_sayisi"],
"Faiz Getirisi (TL)": round(sonuc["faiz_getirisi"], 2),
"Toplam (TL)": round(sonuc["toplam"], 2)
})
break

with open("musteriler.json", "w", encoding="utf-8") as f:
json.dump(musteriler, f, ensure_ascii=False, indent=4)

messagebox.showinfo("Başarılı", "Müşteri bilgileri güncellendi!")
entry_isim.delete(0, tk.END)
entry_anapara.delete(0, tk.END)
entry_faiz.delete(0, tk.END)
entry_bitis.delete(0, tk.END)
goster_liste_modu()
musterileri_guncelle()

except ValueError:
messagebox.showerror("Hata", "Lütfen geçerli sayısal değerler girin!")
except Exception as e:
messagebox.showerror("Hata", f"Güncelleme başarısız: {str(e)}")

# Butonlar
ekle_btn = ttk.Button(form_frame, text="Müşteri Ekle", command=yeni_musteri_ekle, style="TButton")
ekle_btn.grid(row=6, column=0, columnspan=2, pady=20)

guncelle_btn = ttk.Button(form_frame, text="Güncelle", command=guncelle_musteri, style="TButton")
musteri_listesi_btn = ttk.Button(form_frame, text="Müşterileri Gör", command=goster_liste_modu, style="TButton")
musteri_listesi_btn.grid(row=7, column=0, columnspan=2, pady=10)

btn_frame = ttk.Frame(list_frame, style="TFrame")
btn_frame.pack(pady=10)
ttk.Button(btn_frame, text="Yeni Müşteri Ekle", command=goster_ekleme_modu, style="TButton").pack(side="left", padx=5)
ttk.Button(btn_frame, text="Sil", command=sil_musteri, style="TButton").pack(side="left", padx=5)
ttk.Button(btn_frame, text="Düzenle", command=duzenle_musteri, style="TButton").pack(side="left", padx=5)

# Varsayılan: Liste modu
goster_liste_modu()
musterileri_guncelle()

root.mainloop()
pyinstaller ile exe ye çevirebilirsin.

Bu içeriği görüntülemek için üçüncü taraf çerezlerini yerleştirmek için izninize ihtiyacımız olacak.
Daha detaylı bilgi için, çerezler sayfamıza bakınız.
 
Pyinstaller ile EXE'ye çevirirken hata almanız doğal çünkü DateEntry bileşeniyle ttkbootstrap arasında uyumsuzluk var. from tkcalendar import DateEntry satırını from ttkbootstrap.widgets import DateEntry olarak güncelledim. Ayrıca date_pattern="yyyy-mm-dd" parametresini kaldırdım ve entry_bit.delete(0, tk.END) satırını sildim (yeni DateEntry sınıfı delete metodunu desteklemiyor).

Kodun güncel hali:

Python:
import tkinter as tk
from tkinter import messagebox
from tkinter import ttk
from ttkbootstrap import Style, Window
import json
import os
from datetime import datetime
from ttkbootstrap.widgets import DateEntry
import uuid

# Faiz hesaplama fonksiyonları
def gunluk_bilesik_faiz(anapara, gun_sayisi, yillik_faiz_orani):
    oran = (yillik_faiz_orani / 100) / 365
    toplam = anapara * (1 + oran) ** gun_sayisi
    return toplam - anapara, toplam

def tarih_farki(baslangic, bitis):
    bas = datetime.strptime(baslangic, "%Y-%m-%d")
    bit = datetime.strptime(bitis, "%Y-%m-%d")
    return (bit - bas).days

def musteri_hesapla(anapara, faiz, bas_tarih, bit_tarih):
    fark = tarih_farki(bas_tarih, bit_tarih)
    if fark < 0:
        return None, "Tarih hatalı"
    getiri, toplam = gunluk_bilesik_faiz(anapara, fark, faiz)
    return {"gun": fark, "getiri": getiri, "toplam": toplam}, None

def musterileri_yukle():
    if not os.path.exists("musteriler.json"):
        return []
    try:
        with open("musteriler.json", "r", encoding="utf-8") as f:
            return json.load(f)
    except Exception as e:
        messagebox.showerror("Hata", f"Veri yüklenemedi: {e}")
        return []

def kaydet(isim, anapara, faiz, bas_tarih, bit_tarih):
    try:
        data = musterileri_yukle()
        sonuc, hata = musteri_hesapla(anapara, faiz, bas_tarih, bit_tarih or datetime.now().strftime("%Y-%m-%d"))
        if hata:
            return None, hata

        musteri = {
            "ID": str(uuid.uuid4()),
            "İsim": isim,
            "Anapara": anapara,
            "Faiz": faiz,
            "Başlangıç": bas_tarih,
            "Bitiş": bit_tarih or datetime.now().strftime("%Y-%m-%d"),
            "Gün": sonuc["gun"],
            "Getiri": round(sonuc["getiri"], 2),
            "Toplam": round(sonuc["toplam"], 2)
        }
        data.append(musteri)
        with open("musteriler.json", "w", encoding="utf-8") as f:
            json.dump(data, f, ensure_ascii=False, indent=4)
        return True, None
    except Exception as e:
        return None, str(e)

# GUI Başlat
root = Window(themename="darkly")
root.title("AĞCA TARIM")
root.geometry("1000x700")
style = Style()

# Stil tanımı
style.configure("TLabel", font=("Roboto", 12))
style.configure("TButton", font=("Roboto", 12, "bold"))

# Başlık
ttk.Label(root, text="AĞCA TARIM", font=("Roboto", 28, "bold"), foreground="#00BFFF", background="#1C2526").pack(pady=20)

main_frame = ttk.Frame(root)
main_frame.pack(fill="both", expand=True, padx=20, pady=10)

form = ttk.Frame(main_frame)
form.pack(pady=20)

ttk.Label(form, text="Müşteri İsmi:").grid(row=0, column=0, sticky="e", pady=5)
entry_isim = ttk.Entry(form)
entry_isim.grid(row=0, column=1, padx=10)

ttk.Label(form, text="Anapara (TL):").grid(row=1, column=0, sticky="e", pady=5)
entry_anapara = ttk.Entry(form)
entry_anapara.grid(row=1, column=1, padx=10)

ttk.Label(form, text="Yıllık Faiz (%):").grid(row=2, column=0, sticky="e", pady=5)
entry_faiz = ttk.Entry(form)
entry_faiz.grid(row=2, column=1, padx=10)

ttk.Label(form, text="Başlangıç Tarihi:").grid(row=3, column=0, sticky="e", pady=5)
entry_bas = DateEntry(form, dateformat="%Y-%m-%d")
entry_bas.grid(row=3, column=1, padx=10)

ttk.Label(form, text="Bitiş Tarihi (Ops.):").grid(row=4, column=0, sticky="e", pady=5)
entry_bit = DateEntry(form, dateformat="%Y-%m-%d")
entry_bit.grid(row=4, column=1, padx=10)

# Liste Alanı
liste_frame = ttk.Frame(main_frame)
tree = ttk.Treeview(liste_frame, columns=("İsim", "Anapara", "Faiz", "Başlangıç", "Bitiş", "Gün", "Getiri", "Toplam"), show="headings")
for col in tree["columns"]:
    tree.heading(col, text=col)
    tree.column(col, width=120)
tree.pack(fill="both", expand=True)
scroll = ttk.Scrollbar(liste_frame, orient="vertical", command=tree.yview)
tree.configure(yscrollcommand=scroll.set)
scroll.pack(side="right", fill="y")

# Fonksiyonlar
def musteri_ekle():
    try:
        isim = entry_isim.get()
        anapara = float(entry_anapara.get())
        faiz = float(entry_faiz.get())
        bas = entry_bas.entry.get()
        bit = entry_bit.entry.get() or None
        if not isim:
            messagebox.showerror("Hata", "İsim gerekli")
            return
        ok, hata = kaydet(isim, anapara, faiz, bas, bit)
        if hata:
            messagebox.showerror("Hata", hata)
            return
        messagebox.showinfo("Başarılı", "Müşteri eklendi")
        entry_isim.delete(0, tk.END)
        entry_anapara.delete(0, tk.END)
        entry_faiz.delete(0, tk.END)
        entry_bit.entry.delete(0, tk.END)
        musteri_listele()
    except ValueError:
        messagebox.showerror("Hata", "Geçersiz değer girdiniz")

def musteri_listele():
    tree.delete(*tree.get_children())
    for m in musterileri_yukle():
        tree.insert("", tk.END, values=(m["İsim"], m["Anapara"], m["Faiz"], m["Başlangıç"], m["Bitiş"], m["Gün"], m["Getiri"], m["Toplam"]))

# Butonlar
btn_frame = ttk.Frame(root)
btn_frame.pack(pady=10)
ttk.Button(btn_frame, text="Ekle", command=musteri_ekle).pack(side="left", padx=5)
ttk.Button(btn_frame, text="Listele", command=musteri_listele).pack(side="left", padx=5)

liste_frame.pack(fill="both", expand=True, padx=10, pady=10)

musteri_listele()
root.mainloop()

PyInstaller ile EXE'ye çevrilmiş halinin indirme linki: Dropbox
 
Son düzenleme:
Çözüm
PyInstaller ile EXE'ye çevirirken hata almanız doğal çünkü dateentry bileşeniyle ttkbootstrap arasında uyumsuzluk var. from tkcalendar import DateEntry satırını from ttkbootstrap.widgets import DateEntry olarak güncelledim. Ayrıca date_pattern="yyyy-mm-dd" parametresini kaldırdım ve entry_bit.delete(0, tk.END) satırını sildim (yeni dateentry sınıfı delete metodunu desteklemiyor).

Kodun güncel hali:

Python:
import tkinter as tk.
from tkinter import messagebox.
from tkinter import ttk.
from ttkbootstrap import Style, Window.
import json.
import os.
from datetime import datetime.
from ttkbootstrap.widgets import DateEntry.
import uuid.

# Faiz hesaplama fonksiyonları.
def gunluk_bilesik_faiz(anapara, gun_sayisi, yillik_faiz_orani):
 oran = (yillik_faiz_orani / 100) / 365.
 toplam = anapara * (1 + oran) ** gun_sayisi.
 return toplam - anapara, toplam.

def tarih_farki(baslangic, bitis):
 bas = datetime.strptime(baslangic, "%Y-%m-%d")
 bit = datetime.strptime(bitis, "%Y-%m-%d")
 return (bit - bas).days

def musteri_hesapla(anapara, faiz, bas_tarih, bit_tarih):
 fark = tarih_farki(bas_tarih, bit_tarih)
 if fark < 0:
 return None, "Tarih hatalı"
 getiri, toplam = gunluk_bilesik_faiz(anapara, fark, faiz)
 return {"gun": fark, "getiri": getiri, "toplam": toplam}, None.

def musterileri_yukle():
 if not os.path.exists("musteriler.json"):
 return []
 try:
 with open("musteriler.json", "r", encoding="utf-8") as f:
 return json.load(f)
 except Exception as e:
 messagebox.showerror("Hata", f"Veri yüklenemedi: {e}")
 return []

def kaydet(isim, anapara, faiz, bas_tarih, bit_tarih):
 try:
 data = musterileri_yukle()
 sonuc, hata = musteri_hesapla(anapara, faiz, bas_tarih, bit_tarih or datetime.now().strftime("%Y-%m-%d"))
 if hata:
 return None, hata.

 musteri = {
 "ID": str(uuid.uuid4()),
 "İsim": isim,
 "Anapara": anapara,
 "Faiz": faiz,
 "Başlangıç": bas_tarih,
 "Bitiş": bit_tarih or datetime.now().strftime("%Y-%m-%d"),
 "Gün": sonuc["gun"],
 "Getiri": round(sonuc["getiri"], 2),
 "Toplam": round(sonuc["toplam"], 2)
 }
 data.append(musteri)
 with open("musteriler.json", "w", encoding="utf-8") as f:
 json.dump(data, f, ensure_ascii=False, indent=4)
 return True, None.
 except Exception as e:
 return None, str(e)

# GUI Başlat.
root = Window(themename="darkly")
root.title("AĞCA TARIM")
root.geometry("1000x700")
style = Style()

# Stil tanımı.
style.configure("TLabel", font=("Roboto", 12))
style.configure("TButton", font=("Roboto", 12, "bold"))

# Başlık.
ttk.Label(root, text="AĞCA TARIM", font=("Roboto", 28, "bold"), foreground="#00BFFF", background="#1C2526").pack(pady=20)

main_frame = ttk.Frame(root)
main_frame.pack(fill="both", expand=True, padx=20, pady=10)

form = ttk.Frame(main_frame)
form.pack(pady=20)

ttk.Label(form, text="Müşteri İsmi:").grid(row=0, column=0, sticky="e", pady=5)
entry_isim = ttk.Entry(form)
entry_isim.grid(row=0, column=1, padx=10)

ttk.Label(form, text="Anapara (TL):").grid(row=1, column=0, sticky="e", pady=5)
entry_anapara = ttk.Entry(form)
entry_anapara.grid(row=1, column=1, padx=10)

ttk.Label(form, text="Yıllık Faiz (%):").grid(row=2, column=0, sticky="e", pady=5)
entry_faiz = ttk.Entry(form)
entry_faiz.grid(row=2, column=1, padx=10)

ttk.Label(form, text="Başlangıç Tarihi:").grid(row=3, column=0, sticky="e", pady=5)
entry_bas = DateEntry(form, dateformat="%Y-%m-%d")
entry_bas.grid(row=3, column=1, padx=10)

ttk.Label(form, text="Bitiş Tarihi (Ops.):").grid(row=4, column=0, sticky="e", pady=5)
entry_bit = DateEntry(form, dateformat="%Y-%m-%d")
entry_bit.grid(row=4, column=1, padx=10)

# Liste Alanı.
liste_frame = ttk.Frame(main_frame)
tree = ttk.Treeview(liste_frame, columns=("İsim", "Anapara", "Faiz", "Başlangıç", "Bitiş", "Gün", "Getiri", "Toplam"), show="headings")
for col in tree["columns"]:
 tree.heading(col, text=col)
 tree.column(col, width=120)
tree.pack(fill="both", expand=True)
scroll = ttk.Scrollbar(liste_frame, orient="vertical", command=tree.yview)
tree.configure(yscrollcommand=scroll.set)
scroll.pack(side="right", fill="y")

# Fonksiyonlar.
def musteri_ekle():
 try:
 isim = entry_isim.get()
 anapara = float(entry_anapara.get())
 faiz = float(entry_faiz.get())
 bas = entry_bas.entry.get()
 bit = entry_bit.entry.get() or None.
 if not isim:
 messagebox.showerror("Hata", "İsim gerekli")
 return.
 ok, hata = kaydet(isim, anapara, faiz, bas, bit)
 if hata:
 messagebox.showerror("Hata", hata)
 return.
 messagebox.showinfo("Başarılı", "Müşteri eklendi")
 entry_isim.delete(0, tk.END)
 entry_anapara.delete(0, tk.END)
 entry_faiz.delete(0, tk.END)
 entry_bit.entry.delete(0, tk.END)
 musteri_listele()
 except ValueError:
 messagebox.showerror("Hata", "Geçersiz değer girdiniz")

def musteri_listele():
 tree.delete(*tree.get_children())
 for m in musterileri_yukle():
 tree.insert("", tk.END, values=(m["İsim"], m["Anapara"], m["Faiz"], m["Başlangıç"], m["Bitiş"], m["Gün"], m["Getiri"], m["Toplam"]))

# Butonlar.
btn_frame = ttk.Frame(root)
btn_frame.pack(pady=10)
ttk.Button(btn_frame, text="Ekle", command=musteri_ekle).pack(side="left", padx=5)
ttk.Button(btn_frame, text="Listele", command=musteri_listele).pack(side="left", padx=5)

liste_frame.pack(fill="both", expand=True, padx=10, pady=10)

musteri_listele()
root.mainloop()

PyInstaller ile EXE'ye çevrilmiş halinin indirme linki: Dropbox

Çok sağ olun hocam.
 

Technopat Haberler

Geri
Yukarı