CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

CTkCheckBox's dynamical onvalue & offvalue not to be assigned in a loop (except the final one)

Open duruburak opened this issue 3 years ago • 0 comments

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?

duruburak avatar Dec 26 '22 15:12 duruburak