bind in Tkinter

VK "myname" at example.invalid
Fri Jun 10 16:53:21 EDT 2005


Shankar Iyer (siyer at Princeton.EDU) wrote:
> 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
> 
> 
Have you defined quit function?



More information about the Python-list mailing list