CustomTkinter
CustomTkinter copied to clipboard
CTkCheckBox's dynamical onvalue & offvalue not to be assigned in a loop (except the final one)
When I try to dynamically assign on and off values to checkboxes it doesn't work except the last checkbox.
def check(self):
print(self.get())
root = customtkinter.CTk()
for i in range(4):
checkbox = customtkinter.CTkCheckBox(root, height=70, width=15, text="", onvalue=i, offvalue=-1, command = lambda: check(checkbox))
checkbox.pack(side=LEFT, pady=3, padx=7, ipadx=0, ipady=0, expand=False)
root.mainloop()
If I press the each checkbox twice (on and off), this is the output:
-1
-1
-1
-1
-1
-1
3
-1
I also tried to put each checkbox into a list, same result. What causes this, any ideas?