bind in Tkinter

Shankar Iyer (siyer@Princeton.EDU) siyer at Princeton.EDU
Fri Jun 10 16:16:14 EDT 2005


I have been trying to learn how to associate keyboard events with actions taken by a Python program using Tkinter.  From what I've read online, it seems that this is done with the bind methods.  In one of my programs, I have included the following:

self.enternumber = Entry(self)
self.enternumber.bind("<Return>",self.quit)
self.enternumber.pack({"side":"top"})

It seems to me that, as a result of this code, if the enternumber Entry widget is selected and then the <Return> key is pressed, then the program should quit.  Indeed, it seems that the program does attempt to quit, but instead an error message appears claiming that quit() takes 1 argument but 2 are given.  I get the same type of error if I replace self.quit with some function that I have written.  I am not sure how to fix this problem and hope that someone here can spot my error.  Thanks for your help.

Shankar





More information about the Python-list mailing list