The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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()