I want to add several Checkbutton in my Tkinter app. I don't know the number of Checkbutton I insert when I launch the program (depend on a DB call).
I wrote this code:
for row in information:
self.__checkBoxValue.append(StringVar())
Checkbutton(self.__frame2, variable=self.__checkBoxValue[-1], onvalue="%s*%s" % (row[0], row[1])).grid(row=TDMUsed[row[0]], column=DateUsed[row[2]])
When I run the code, all the checkbox are grayed and checked. But,开发者_如何学Go If I delete the variable option, the checkbox is ok.
Try setting the value of the StringVar
instance to either your onvalue
or offvalue
.
精彩评论