将功能输出到文本框tkinter

时间:2018-11-20 12:00:35

标签: 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 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()框

1 个答案:

答案 0 :(得分:0)

当您将第一个下拉按钮添加到菜单时,您试图将其放入菜单“ newMeasures”中,该菜单不存在。

menu.add_cascade(label="New Measures", menu=newMeasures)

您创建的菜单称为“文件菜单”。

menu.add_cascade(label="New Measures", menu=filemenu)