psham (1) [Avatar] Offline
#1
This is what I have :

import os
from Tkinter import *

class App:

def __init__(self, master):
self.var = IntVar()
c = Checkbutton(master, text="Enable Tab",
variable=self.var, command=self.cb)
c.pack()
def cb(self, event):
print "variable is", self.var.get()

root = Tk()
app = App(root)
root.mainloop()

----------------------------------------------------------------------------------------------------------------
I get error :

Exception in Tkinter callback
Traceback (most recent call last):
File "Csmilieython23liblib-tkTkinter.py", line 1345, in __call__
return self.func(*args)
TypeError: cb() takes exactly 2 arguments (1 given)


Can someone please help resolve this exception
Jabapyth (9) [Avatar] Offline
#2
Re: TypeError: cb() takes exactly 2 arguments (1 given)
def cb(self,event=None):
    print "variable is", self.var.get()