Python 特金特·梅努巴

Python 特金特·梅努巴,python,tkinter,menubar,Python,Tkinter,Menubar,我刚开始学习Tkinter,在制作菜单栏时遇到了一个问题,因为附带了错误和代码。提前谢谢 from tkinter import * root = Tk() root.title("HP SIMPLE FINANCE") w, h = root.winfo_screenwidth(), root.winfo_screenheight() root.geometry("%dx%d+0+0" % (w, h)) def donothing(): pass menubar = Menu

我刚开始学习Tkinter,在制作菜单栏时遇到了一个问题,因为附带了错误和代码。提前谢谢

from tkinter import *

root = Tk()
root.title("HP SIMPLE FINANCE")

w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.geometry("%dx%d+0+0" % (w, h))

def donothing():
    pass

menubar = Menu(root)
root.config(menu=menubar)

filemenu = Menu(menubar)
menubar.add_cascade(label="File", Menu=filemenu)
filemenu.add_command(label="Open Portfolio file", command=donothing)
filemenu.add_command(label="New Portfolio", command=donothing)
filemenu.add_command(label="Reports", command=donothing)
filemenu.add_command(label="Restore from backup", command=donothing)
filemenu.add_command(label="Exit", command=root.quit)

root.mainloop()
文件“F:/Finance software/Main window.py”,第28行,在
menubar.add_级联(label=“File”,Menu=filemenu)
文件“C:\Users\harshparmar\AppData\Local\Programs\Python\Python38-32\lib\tkinter\\ uuu init\uuu.py”,第3289行,添加级联
自加('cascade',cnf或kw)
文件“C:\Users\harshparmar\AppData\Local\Programs\Python\Python38-32\lib\tkinter\\uuuuu init\uuuu.py”,第3284行,添加
self.tk.call((self._w'add',itemType)+
_tkinter.TclError:未知选项“-菜单”
流程已完成,退出代码为1

menubar.add_cascade(label="File", Menu=filemenu)


非常感谢你,m0mandap。它成功了。你能帮我找出或阅读并解释错误吗?
Menu
这一行的菜单栏应全部小写。添加级联(label=“File”,Menu=filemenu)
menubar.add_cascade(label="File", Menu=filemenu)
menubar.add_cascade(label="File", menu=filemenu)