On 15.10.2011 19:30, Gary wrote:
Hi im trying to use key bind on Tkinter to call this function

def Start():
for i in range(60,-1,-1):
ent['text'] = i
time.sleep(1)
root.update()
ent['text'] = 'Time Out!'
root.update()

i know the function is ok as i have assigned a button and i calls
the function as i expect
but
root.bind('<a>',Start)
gives the following error

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
TypeError: Start() takes no arguments (1 given)

Thanks

As the error indicates, the callback function is called with an argument, but you don't provide one. That argument is an Event instance, so you can get details about the event.

Use

def Start(event):
    ...

BTW. functions, unlike classes should be all lower-case.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to