Jul-07-2020, 03:43 PM
(This post was last modified: Jul-07-2020, 03:43 PM by deanhystad.)
It would be ridiculous if you had to do that. I used a list.
from tkinter import * from tkinter import ttk mw = Tk() mw.geometry('700x300+400+200') frame3 = Frame(mw) framebot = Frame(mw) frame3.pack(side=TOP,fill=X) framebot.pack(side=BOTTOM,fill=X) w3 = Label(frame3, text="Checkbuttons: ",font=("Times",16)).grid(row=0,column=0) check_buttons = [] for i in range(1, 7): value = BooleanVar() button = ttk.Checkbutton(frame3, text=str(i), variable=value) check_buttons.append(value) # <--- Value variables saved here!!!! value.set(i % 2 == 0) button.grid(row=i,column=0) mw.mainloop()There often isn't a reason to keep the handle to the control after it is placed and treat the variable as a well designed control that does what you really want.