0

I have a program that makes several button widgets. This buttons have the same callbacks, named show_info(). My problem is that I need to plot all the info inside a var related to this button. I try to do a callback giving the var where I have the info, but what really happens is that i send the value related to the last button ploted, so click whatever button you get the last widget plot info. The variable t is where the information for each button is kept.

def show_task_info(t):
    task_info_win = Toplevel()
    tinfo_widg_list=[]
    row=0
    for i in t.requirements:
        Label(task_info_win, text=i+' : ').grid(row=row,column=0)
        Label(task_info_win, text=t.requirements[i]).grid(row=row, column=1)
        row+=1

def plot_scheduler():
    sch_widg_list = []
    n=0
    for i in scheduler.sorted_list:
        t=i[1]
        widg=Button(root, text=t.name+' '+str(n), command=lambda :show_task_info(t))
        sch_widg_list.append((widg,n))
        n+=1
        if n>14:
            break
    #plot them into the screen
    for widg, ndex in sch_widg_list:
        widg.grid(row=3, column=ndex, pady=10)
CrMatt9
  • 33
  • 6

0 Answers0