Reputation: 1
The program shows about 100 graphs I want to let the user the option to choose which graphs he wants to see, so there will be less graphs to present. For this purpose, I thought to use checkboxes.
The problem is that whenever a checkbox is selected, the last checkbox\text from the while loop is being sent to the callback function
I've tried several ways to send the String:site to the callback, here are two of them:
for site in PcapLogic.deciphered_bin_df.columns:
# create widgets
self.btns.append(btn := ttk.Checkbutton(scrolled_text, text=site, style="Custom.TCheckbutton"))
self.vars.append(var := tk.StringVar(btn, site, site))
# add command to button
btn.configure(variable = var, onvalue=site, offvalue="", command=lambda: AppBoot.add_new_param_to_ini(var.get()))
# btn.configure(variable = var, onvalue=site, offvalue="", command=lambda: AppBoot.add_new_param_to_ini(btn['text']))
Output:
mgr
mgr
mgr
mgr
the checkboxes which I selected are: google, brave, facebook, insta but the names that were sent to the callback function are: "mgr", "mgr", "mgr", "mgr".
Where "mgr" is the last graph\site_name\text that is inserted in the for loop
I'm interested in the reason for this bug. So my question is, why is the last element from the loop is being sent to callback function each event?
Upvotes: 0
Views: 14