Python 将函数输出到文本框中,tkinter

Python 将函数输出到文本框中,tkinter,python,tkinter,sqlite,Python,Tkinter,Sqlite,你能帮我吗?我正在尝试创建跟随函数的按钮,然后在文本框中输出,这是我目前的代码: root = Tk() menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) root.filemenu = filedialog.askopenfilename() menu.add_cascade(label="New Measures", menu=newMeasures) filemenu.add_command(label="See

你能帮我吗?我正在尝试创建跟随函数的按钮,然后在文本框中输出,这是我目前的代码:

root = Tk()
menu = Menu(root)
root.config(menu=menu)
filemenu = Menu(menu)
root.filemenu = filedialog.askopenfilename()
menu.add_cascade(label="New Measures", menu=newMeasures)
filemenu.add_command(label="See all measures", command=getMeasures)
filemenu.add_command(label="See the total rain", command=totalRain)
filemenu.add_command(label="See the total electricity", command=totalElectricity)
filemenu.add_command(label="See the measures for a date", command=find_date)
#filemenu.add_command(label="Change the data for a date", command=edit_date)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.destroy)

但它什么也没做——当您将第一个下拉按钮添加到菜单时,它只是显示一个空的tk()框,您试图将其放入“newMeasures”菜单中,而该菜单不存在

menu.add_cascade(label="New Measures", menu=newMeasures)
您创建的菜单称为“文件菜单”


您的代码不会创建任何文本框并引发
namererror
.1。您没有在此代码中使用文本框。2.
root.filemenu
对于变量来说是个糟糕的名字,老实说,我甚至认为
root.filemenu
是行不通的。3.您有所有这些标签,每个标签都有不同的命令,但是您没有显示这些函数在做什么,因此无法知道代码有什么问题。4.您还需要包括正在使用的导入。
menu.add_cascade(label="New Measures", menu=filemenu)