Python 我想用keyword()函数获取关键字来搜索google图像。我该怎么修

Python 我想用keyword()函数获取关键字来搜索google图像。我该怎么修,python,selenium,user-interface,tkinter,Python,Selenium,User Interface,Tkinter,导入操作系统 将tkinter.ttk作为ttk导入tkinter.messagebox作为msgbox从 特金特进口 从tkinter导入文件对话框 从PIL导入图像 root=Tk()root.title(“Nado GUI”) def关键字(): 关键字。get() 关键字.delete(0,结束) def google_image(): 文件\u frame=frame(根)文件\u frame.pack(fill=“x”,padx=5,pady=5)> btn_关键字=按钮(文件框架,

导入操作系统 将tkinter.ttk作为ttk导入tkinter.messagebox作为msgbox从 特金特进口 从tkinter导入文件对话框 从PIL导入图像 root=Tk()root.title(“Nado GUI”)

def关键字(): 关键字。get() 关键字.delete(0,结束)

def google_image():

文件\u frame=frame(根)文件\u frame.pack(fill=“x”,padx=5,pady=5)>

btn_关键字=按钮(文件框架,text=“单击”,命令=关键字) btn_关键字.pack(side=“right”,padx=5,pady=5)关键字= 条目(文件\框架,宽度=30)关键字.pack(side=“right”,padx=5,pady=5)

frame_run=frame(root)frame_run.pack(fill=“x”,padx=5,pady=5)

btn_close=按钮(frame_run,padx=5,pady=5,text=“close”,width=12,command=root.quit) btn_close.pack(side=“right”,padx=5,pady=5)

btn_start=按钮(frame_run,padx=5,pady=5,text=“start”,width=12,command=google_image) btn_启动包(side=“right”,padx=5,pady=5)

根目录。可调整大小(False,False)

root.mainloop()


您的主要问题是对函数和小部件使用了相同的名称
关键字

你应该用不同的名字

keyword_entry = Entry(...)
然后

def keyword():
    value = keyword_entry.get()
    keyword_entry.delete(0, END)
    return value
然后你就可以使用它了

elem.send_keys(keyword())

编辑问题并为
代码示例使用函数(带有
{}
的按钮),而不是
块引号
。在问题的正文中描述问题,而不是在标题中不要对函数的名称
定义关键字(…)
和其他变量
关键字=条目(…)使用相同的名称
关键字
最好使用
def get_关键字():return关键字。get()
elem.send_keys(keyword())