I have made a code where u type your name, birth year, month, day , and weather you're a male or a female and each answer will be listed into a listbox. whats below is an image of my guiimage of my gui
the problem is that when i put in the age of someone that is 13 and the age of someoe that is 15, the listbox won't organize the ages from oldest to youngest.
this us what my code looks like
from cmath import e
from tkinter import*
from datetime import date
from tkinter import messagebox
one = Tk()
one.title("NICE")
one.state("zoomed")
today = date.today()
clicked = StringVar()
clicked.set("Male")
def adi():
a.insert(END, three.get())
def gen():
if clicked.get() == "Male":
b.insert(END, three.get())
else:
c.insert(END, three.get())
def age():
d= int(birth_day.get())
m=int(birth_month.get())
y=int(birth_year.get())
age = today.year-y-((today.month, today.day)<(m,d))
d1.insert(END, age)
two = [
"Male",
"Female"
]
frame = Frame(one)
frame.pack(pady=5)
lf = Frame(frame)
lf.pack(pady=5)
my_label = Label(lf, font=("Futura", 40),fg="#FFFFFF", text="Name")
my_label.pack(side=LEFT, fill=BOTH, padx=120)
a = Listbox(frame,
font=("Futura", 25),
width=20,
height=6,
bd=2,
fg='#FFFFFF'
)
a.pack(side=LEFT, fill=BOTH, padx=10)
my_label = Label(lf, font=("Futura", 40),fg="#FFFFFF", text="Male")
my_label.pack(side=LEFT, fill=BOTH, padx=120)
b = Listbox(frame,
font=("Futura", 25),
width=20,
height=6,
bd=2,
fg='#FFFFFF'
)
b.pack(side=LEFT, fill=BOTH, padx=10)
my_label = Label(lf, font=("Futura", 40),fg="#FFFFFF", text="Female")
my_label.pack(side=LEFT, fill=BOTH, padx=120)
c = Listbox(frame,
font=("Futura", 25),
width=20,
height=6,
bd=2,
fg='#FFFFFF'
)
c.pack(side=LEFT, fill=BOTH,padx=10)
my_label = Label(lf, font=("Futura", 40),fg="#FFFFFF", text="Age")
my_label.pack(side=LEFT, fill=BOTH, padx=120)
d1 = Listbox(frame,
font=("Futura", 25),
width=20,
height=6,
bd=2,
fg='#FFFFFF'
)
d1.pack(side=LEFT, fill=BOTH, padx=10)
frame2 = Frame(one)
frame2.pack(pady=20)
three = Entry(frame2, font=("Futura", 30))
three.pack(pady=20)
age1 = Frame(frame2)
age1.pack(pady=10)
lbf = Frame(age1)
lbf.pack()
Label(lbf, text="Birth Year", font=("Futura", 30)).pack(pady=10, side=LEFT, padx=150)
Label(lbf, text="Birth Month", font=("Futura", 30)).pack(pady=10, side=LEFT, padx=120)
Label(lbf, text="Birth Date", font=("Futura", 30)).pack(pady=10, side=LEFT, padx=150)
yearvalue = StringVar()
monthvalue = StringVar()
dayvalue = StringVar()
birth_year = Entry(age1, textvariable=yearvalue, font=("Futura", 30))
birth_year.pack(pady=20, padx=20, side=LEFT)
birth_month = Entry(age1, textvariable=monthvalue, font=("Futura", 30))
birth_month.pack(pady=20, padx=20, side=LEFT)
birth_day = Entry(age1, textvariable=dayvalue, font=("Futura", 30))
birth_day.pack(pady=20, padx=20, side=LEFT)
drop = OptionMenu(frame2, clicked, *two ).pack(pady=10)
add = Button(frame2, text="Submit", command=lambda:[adi(), gen(), age()]).pack()
#LABEL/BUTTON
one.mainloop()
could someone help me figure out what i should add to make this work?
list
and then you can call thesorted()
method on the list before you add them to your listbox.ttk.Treeview
widget instead of 4 listboxes.