Python TypeError:search_country()接受0个位置参数,但给出了1个

Python TypeError:search_country()接受0个位置参数,但给出了1个,python,button,tkinter,bind,tkinter-entry,Python,Button,Tkinter,Bind,Tkinter Entry,我使用Tkinter,有一个条目和一个“搜索”按钮。如果我们在条目中输入一个文本并点击搜索按钮,效果会很好。它调用了一个名为search\u country的函数。 但是,如果我们点击搜索按钮或只按回车键,我想呼叫搜索国家。然后我绑定这个:entry.bind(“”,search\u country),它显示了这个错误 entry = Entry(win) entry.grid(row=0, column=1) entry.bind('<Return>', search_countr

我使用Tkinter,有一个条目和一个“搜索”按钮。如果我们在条目中输入一个文本并点击搜索按钮,效果会很好。它调用了一个名为search\u country的函数。 但是,如果我们点击搜索按钮或只按回车键,我想呼叫搜索国家。然后我绑定这个:entry.bind(“”,search\u country),它显示了这个错误

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)
entry=entry(赢)
entry.grid(行=0,列=1)
条目绑定(“”,搜索国家/地区)
按钮搜索=按钮(f2,text=“search”,command=搜索国家)
按钮搜索网格(行=0,列=2)
def search_country():
search_=”“.join(entry.get().split()).title().replace('And','&'))
条目。删除(0,“结束”)
如果在国家/地区搜索:
国家索引=国家索引(搜索)
列表框。选择内容\u清除(0,结束)
列表框。选择集合(国家索引)
showimg(国家/地区指数)
我尝试了很多方法,但我只得到了两种方法中的一种:点击搜索按钮或在条目中按enter键。我需要两种方法正确工作

多谢各位

当你这样做的时候

entry.bind('<Return>', search_country)

当单击
搜索
按钮时,某些文档

调用了相同的函数,该按钮不希望回调函数有任何参数,那么它将引发错误。将函数签名改为
def search\u country(event=None):
。非常感谢您的回答。我会仔细阅读文档,然后再试一次。
def search_country(event):