Here is a little code example I found on the Effbot website which is close to what I want to do in one of my programs:
from Tkinter import *
fen =Tk()
class test_Tk_class:
def __init__(self):
self.var = IntVar()
c = Checkbutton(
fen, text="Enable Tab",
variable=self.var,
command=self.cb)
c.pack()
def cb(self,event):
print "variable is", self.var.get()
a = test_Tk_class()
fen.mainloop()
However this code is not working. The callback function cb
does not work because it takes 2 arguments and none are given. How do you specify the event
argument?
event=None
so that the callbacks will work for button and bindings – Covenantor