I use Tkinter and have an entry and a button "search". It works well if we enter a text in the entry and hit the search button. It called a function named search_country. However, I would like to call the search_country if we hit the search button or just press enter. Then I bind this : entry.bind('', search_country) and it showed that error.
entry = Entry(win)
entry.grid(row=0, column=1)
entry.bind('<Return>', search_country)
button_search = Button(f2, text="Search", command= search_country)
button_search.grid(row=0, column=2)
def search_country():
search_ = " ".join(entry.get().split()).title().replace('And','&')
entry.delete(0,"end")
if search_ in countries:
country_index= countries.index(search_)
listbox.selection_clear(0, END)
listbox.select_set(country_index)
showimg(country_index)
I try many ways but I get only one of two: hit the button search or press enter in the entry. I need two ways work correctly.
Thank you.