How To Bind The Enter Key To A Button In Tkinter
I have a button: button3 = Button(app, text='Show Members', width=15, command=lambda: showLDAPMembers(yourName,yourPassword)) How do I bind the ENTER key to it? I tried doing: app
Solution 1:
You need to use a lambda if you're passing arguments.
app.bind("<Return>", lambda x: showLDAPMembers(yourName,yourPassword))
The bind
command automatically returns the event that called it, so you need to define and throw away that (with lambda x:
)
Solution 2:
first of all inside your function you need to
def showLDAPMembers(event= None)
then you can use the bind method to listen to your return key
app.bind("<Return>",showLDAPMembers())
I hope my answer helps you
Post a Comment for "How To Bind The Enter Key To A Button In Tkinter"