Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter loops
#1
Hi guys!
I'm an absolute newbie in python.
I have this problem with tk inter:

class months():
    def __init__ (self,name,days_of_the_month,year):
        mesi.name = nome
        mesi.days = days_of_the_month
        mesi.year = year


january= months('January',31,2020)
february= months('February',29,2020)
.
.
.  
december= months('December',31,2020)

months_list = [january,february,........,december]

for i in range(len(months_list)):
    new_LabelFrame = LabelFrame(root,text= months_list[i].name)
    new_LabelFrame.pack()
    new_label = Label(new_LabelFrame,text ='Name: {}\nDays: {}\nYear: {}'.format(months_list[i].name,months_list[i].days,months_list[i].year))
    new_label.pack()
When i run the code, it geerates a windows with 12 LabelFrame containing only the December's month information. Could you please tell me why?
Reply


Messages In This Thread
Tkinter loops - by mattemio - Apr-12-2020, 07:36 AM
RE: Tkinter loops - by deanhystad - Apr-12-2020, 09:58 AM
RE: Tkinter loops - by mattemio - Apr-12-2020, 11:43 AM
RE: Tkinter loops - by Yoriz - Apr-12-2020, 12:04 PM
RE: Tkinter loops - by mattemio - Apr-12-2020, 12:33 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020