self.mb = Menubutton ( self.window2, text="Sound Toggler", relief=RAISED ) self.mb.grid(row=4, column = 0) self.mb.menu = Menu ( self.mb, tearoff = 0 ) self.mb["menu"] = self.mb.menu self.ONSound = IntVar() self.ONSound.set(1) self.OFFSound = IntVar() self.OFFSound.set(0) self.mb.menu.add_checkbutton ( label="ONSound", variable=self.ONSound, command = self.turnON(), onvalue=1,offvalue=0) self.mb.menu.add_checkbutton ( label="OFFSound", variable=self.OFFSound, command = self.turnOFF(), onvalue=1,offvalue=0) def turnON(self): self.ONSound.set(1) self.OFFSound.set(0) def turnOFF(self): self.ONSound.set(0) self.OFFSound.set(1)
My goal is to turn these two check buttons to toggle sound On and OFF and in doing so only one of these check buttons can be on/off at a single time. Currently this effect is not working and I've been looking at my code for an hour and can't find the problem. Everything shows up when my full program is run but this ON/OFF toggle doesn't work how I want it to.
All help is appreciated, Thanks