Feb-16-2022, 02:42 PM
Hello, I am having an issue disabling a tkinter checkbutton. I am able to get the value, but when trying to disable it I keep getting the below errors. I have tried StringVar instead of IntVar, but get similar errors. Not sure what am doing wrong. Any help is greatly appreciated! #################### class checkboxes(): #################### #=================== def __init__(self, master): # #=================== self.master = master #=================== def addCheckBox(self, txt, w, h, x, y, fnt, clr, cmd): # #=================== self.var1 = tk.IntVar() self.chkbx= Checkbutton(self.master, width=w, height=h, text=txt, variable=self.var1, onvalue=1, offvalue=0, font=fnt, bg=clr, command=cmd) self.chkbx.config(state="normal") #this works here only self.chkbx.place(x=x, y=y) return self.var1 #=================== def chkbxClick(self): # #=================== print (self) print(self, chkbxItemCard.get()) if chkbxItemCard.get() == 1 or chkbxPicklist.get() == 1 or chkbxQuickPick.get() == 1: btnConvert["state"] = "normal" if chkbxItemCard.get() == 0 and chkbxPicklist.get() == 0 and chkbxQuickPick.get() == 0: btnConvert["state"] = "disabled" # chkbxItemCard.config(state="disabled") #AttributeError: 'IntVar' object has no attribute 'config' # chkbxItemCard["state"] = "disabled" #TypeError: 'IntVar' object does not support item assignment chkbxItemCard = checkboxes.addCheckBox(master, 'TestItemCard', 30, 1, 45, 470, 'Aerial, 15', 'AntiqueWhite1', lambda: checkboxes.chkbxClick("chkItemCard")) #self, txt, w, h, x, y, fnt, clr, cmd