Apr-06-2020, 08:30 AM
(Apr-06-2020, 04:36 AM)deanhystad Wrote: Yes, you can bind both a key and a button to the same function. You were really close with the lambda. All you had to do was throw away the event which you don't care about.
import tkinter as tk root = tk.Tk() root.geometry('250x100') def check_in_database(data, chk): if data in chk: print(f'{data} was found in database.') else: print(f'{data} no match in database.') chk_database = ['Eric', 'John', 'Graham', 'Terry'] field_entry = tk.Entry(root, width=20) field_entry.bind("<Return>", lambda event: check_in_database(field_entry.get(), chk_database)) field_entry.grid(row=0, column=0) tk.Button(root, text='Check database', command=lambda: check_in_database(field_entry.get(), chk_database)) \ .grid(row=0, column=1) root.mainloop()Another useful tool is functools.partial
(Apr-06-2020, 04:36 AM)deanhystad Wrote: Yes, you can bind both a key and a button to the same function.
Thank you! :D