mardi 19 avril 2016

Tkinter: Checkbox variable is always zero

I want to create a checkbox that would invoke an enable function. This works as follows:

self.lol = tk.IntVar(False) self.c = tk.Checkbutton(self, text="Advanced settings", variable=self.lol, command=self.enable()) self.c.grid(column=3,row=5,sticky="EW")

def enable(self): print (self.lol.get()) if self.lol.get()==1: self.advanced() if self.lol.get()==0: try: self.gpuvar.grid_forget() print ("lalka") except: pass

so, enable function is working and as I run the program ,it outputs zero. But when I check the checkbox, no output is generated at all.

Aucun commentaire:

Enregistrer un commentaire