Tkinter arayüz tasarımı hakkında

def fonksiyonunun altinda
3 adet input ve bunlari isleyen bi fonksiyon yazdim.
bu koda arayuz yapmaya calisiyorum ancak cok yeni oldugumdan ve yeterli dokuman bulamadigimdan yapamadim, takildigim nokta fonksiyonu arayuze atamak. tabloyu yaptim ancak kutularin icine girdileri girdigimde sonucu elde edecek sekilde yapamadim.

        print ()
    print ("İZİNLİ GÜN HESAPLAMA PROGRAMI:")
    print ()

    while (True):
        try:
            a=int(input("Lutfen en son izin yaptiginiz tarihi\ngiriniz:"))
            b=int(input("Kac +1 calisiyorsunuz?\n"))
            c=int(input("Lutfen bulundugunuz ayin kac cektigini \nyaziniz:"))
            d=a+b
            b=b+1
        
            if c==30 and int(a+b)==30:
                print("Bir sonraki izin tarihiniz:")
                print(int(30))
            elif c==31 and int(a+b)==30:
                print("Bir sonraki izin tarihiniz:")
                print(int(30))
            elif c==30 and int(a+b)==31:
                print("Bir sonraki izin tarihiniz:")
                print(int(1))
            
            elif c==31 and int(a+b)==31:
                print("Bir sonraki izin tarihiniz:")
                print(int(31))
            
            elif c==30 and d>30 and a==31:
                print("Bir sonraki izin tarihiniz:")
                print(int(a+b)-(a))
            
            elif c==30 and d>30:
                print("Bir sonraki izin tarihiniz:")
                print(int(a+b)-(c))
            
            elif c==31 and d>30:
                print("Bir sonraki izin tarihiniz:")
                print(int(a+b)-(c))
            
            elif c==30 and d<30:
                print("Bir sonraki izin tarihiniz:")
                print(int(a+b))
            
            elif c==31 and d<30:
                print("Bir sonraki izin tarihiniz:")
                print(int(a+b))
            
        except ValueError:
                print()
                print("ERROR ! Bir sayi giriniz...")
                print()
    from tkinter import *



    def gir():
        ensonizin =ensonizinyaptigintarih.get()
        kacarti = kacarti1calisiyorsun.get()
        bulundugunuz = bulundugunuzaykaccekiyor.get()


        while (True):
            try:
                a = int(input("Lütfen en son izin yaptığınız tarihi giriniz:"))
                b = int(input("Kac +1 çalışıyorsunuz?\n"))
                c = int(input("Lütfen bulunduğunuz ayın kaç çektiğini yazınız:"))
                d = a + b
                b = b + 1

                if c == 30 and int((a+b)) == 30:
                    print("Bir sonraki izin tarihiniz:")
                    print(int(30))
                    print()

                elif c == 31 and int((a+b)) == 30:
                    print("Bir sonraki izin tarihiniz:")
                    print(int(30))
                    print()

                elif c == 30 and int((a+b)) == 31:
                    print("Bir sonraki izin tarihiniz:")
                    print(int(1))   
                    print()

                elif c == 31 and int((a+b)) == 31:
                    print("Bir sonraki izin tarihiniz:")
                    print(int(31))
                    print()

                elif c == 30 and d > 30:
                    print("Bir sonraki izin tarihiniz:")
                    print(int(a+b) - (c))
                    print()

                elif c == 31 and d > 30:
                    print("Bir sonraki izin tarihiniz:")
                    print(int(a+b) - (c))
                    print()

                elif c == 30 and d < 30:
                    print("Bir sonraki izin tarihiniz:")
                    print(int(a+b))
                    print()

                elif c == 31 and d < 30:
                    print("Bir sonraki izin tarihiniz:")
                    print(int(a+b))
                    print()

            except ValueError:
                print()
                print("ERROR ! Bir sayı giriniz...")
                print()




    p = Tk()
    p.title("deneme")
    p.geometry("480x360+500+200")
    p.config(bg="black")

    a = Label(p)
    a.config(text="En son izin yaptıgınız tarihi giriniz...:", bg="black", fg="white", font = ("Calibri italic",12))
    a.pack()

    ensonizinyaptigintarih = Entry(p)
    ensonizinyaptigintarih.pack()

    b = Label (p)
    b.config(text="Kac +1 calısıyorsunuz...", bg="black", fg="white", font = ("Calibri italic",12))
    b.pack()

    kacarti1calisiyorsun = Entry(p)
    kacarti1calisiyorsun.pack()

    c = Label(p)
    c.config(text="Bulundugunuz ay kaç cekiyor...", bg="black", fg="white", font = ("Calibri italic",12))
    c.pack()

    bulundugunuzaykaccekiyor = Entry(p)
    bulundugunuzaykaccekiyor.pack()

    girtus = Button(p)
    girtus.config(text="Giris yap", bg="black", fg="white", activebackground="black",
        activeforeground="white", font=("Calibri italic",12), command=gir)

    girtus.pack()

    kntrl = Label (p)
    kntrl.config(text="henuz giris yapilmadi.", bg="black", fg="white", font=("calibri",12))
    mainloop()

Kodlarda biraz değişiklik yaptım, aşağıdakini bir deneyin.

from tkinter import *


def gir():
    try:
        a = int(ensonizinyaptigintarih.get())
        b = int(kacarti1calisiyorsun.get())
        c = int(bulundugunuzaykaccekiyor.get())
        d = a + b
        b = b + 1
        if c == 30 and a + b == 30:
            print("Bir sonraki izin tarihiniz:")
            print(30, end="\n")
        elif c == 31 and a + b == 30:
            print("Bir sonraki izin tarihiniz:")
            print(30, end="\n")
        elif c == 30 and a + b == 31:
            print("Bir sonraki izin tarihiniz:")
            print(1, end="\n")
        elif c == 31 and a + b == 31:
            print("Bir sonraki izin tarihiniz:")
            print(31, end="\n")
        elif c == 30 and d > 30:
            print("Bir sonraki izin tarihiniz:")
            print(a + b - c, end="\n")
        elif c == 31 and d > 30:
            print("Bir sonraki izin tarihiniz:")
            print(a + b - c, end="\n")
        elif c == 30 and d < 30:
            print("Bir sonraki izin tarihiniz:")
            print(a + b, end="\n")
        elif c == 31 and d < 30:
            print("Bir sonraki izin tarihiniz:")
            print(a + b, end="\n")
    except ValueError:
        print()
        print("ERROR ! Bir sayı giriniz...")
        print()


p = Tk()
p.title("deneme")
p.geometry("480x360+500+200")
p.config(bg="black")

l1 = Label(p)
l1.config(text="En son izin yaptıgınız tarihi giriniz...:", bg="black", fg="white", font=("Calibri italic", 12))
l1.pack()

ensonizinyaptigintarih = Entry(p)
ensonizinyaptigintarih.pack()

l2 = Label(p)
l2.config(text="Kac +1 calısıyorsunuz...", bg="black", fg="white", font=("Calibri italic", 12))
l2.pack()

kacarti1calisiyorsun = Entry(p)
kacarti1calisiyorsun.pack()

l3 = Label(p)
l3.config(text="Bulundugunuz ay kaç cekiyor...", bg="black", fg="white", font=("Calibri italic", 12))
l3.pack()

bulundugunuzaykaccekiyor = Entry(p)
bulundugunuzaykaccekiyor.pack()

b1 = Button(p)
b1.config(text="Giris yap", bg="black", fg="white", activebackground="black",
          activeforeground="white", font=("Calibri italic", 12), command=gir)

b1.pack()

kntrl = Label (p)
kntrl.config(text="henuz giris yapilmadi.", bg="black", fg="white", font=("calibri",12))
kntrl.pack()

mainloop()

bir yerde bir hata yapmışım sanırım çalıştı sonucu pencerede göstermiyor o nasıl yapılıyor.

Merhaba.

Yukarıdaki kodlar çalışıyor ancak sonucu uçbirime yazdırıyor. print fonksiyonlarını değiştirerek pencereye yazmasını sağladım, ayrıca kodu biraz sadeleştirdim:

from tkinter import *


def gir():
    try:
        a = int(ensonizinyaptigintarih.get())
        b = int(kacarti1calisiyorsun.get())
        c = int(bulundugunuzaykaccekiyor.get())
        d = a + b
        b = b + 1
        izin = None
        if c == 30 and a + b == 30:
            izin = 30
        elif c == 31 and a + b == 30:
            izin = 30
        elif c == 30 and a + b == 31:
            izin = 1
        elif c == 31 and a + b == 31:
            izin = 31
        elif c == 30 and d > 30:
            izin = a + b - c
        elif c == 31 and d > 30:
            izin = a + b - c
        elif c == 30 and d < 30:
            izin = a + b
        elif c == 31 and d < 30:
            izin = a + b
        if izin:
            kntrl["text"] = "Bir sonraki izin tarihiniz: " + str(izin)
        else:
            kntrl["text"] = "İzin tarihiniz hesaplanamadı."
    except ValueError:
        kntrl["text"] = "ERROR ! Bir sayı giriniz..."


p = Tk()
p.title("deneme")
p.geometry("480x360+500+200")
p.config(bg="black")

l1 = Label(p)
l1.config(text="En son izin yaptıgınız tarihi giriniz...:", bg="black", fg="white", font=("Calibri italic", 12))
l1.pack()

ensonizinyaptigintarih = Entry(p)
ensonizinyaptigintarih.pack()

l2 = Label(p)
l2.config(text="Kac +1 calısıyorsunuz...", bg="black", fg="white", font=("Calibri italic", 12))
l2.pack()

kacarti1calisiyorsun = Entry(p)
kacarti1calisiyorsun.pack()

l3 = Label(p)
l3.config(text="Bulundugunuz ay kaç cekiyor...", bg="black", fg="white", font=("Calibri italic", 12))
l3.pack()

bulundugunuzaykaccekiyor = Entry(p)
bulundugunuzaykaccekiyor.pack()

b1 = Button(p)
b1.config(text="Giris yap", bg="black", fg="white", activebackground="black",
          activeforeground="white", font=("Calibri italic", 12), command=gir)

b1.pack()

kntrl = Label (p)
kntrl.config(text="henuz giris yapilmadi.", bg="black", fg="white", font=("calibri",12))
kntrl.pack()

mainloop()

Kolay gelsin.

ikinize de cok tesekkur ederim cok hizli bir sekilde yardimci oldunuz ozellikle dilde_olupbiten epey ugrasti bana yardim etmek icin.

1 Beğeni