我不断地发现错误:
_tkinter.TclError: unknown option "-menu"
我的MWE看起来像:
from tkinter import *
def hello():
print("hello!")
class Application(Frame):
def createWidgets(self):
self.menuBar = Menu(master=self)
self.filemenu = Menu(self.menuBar, tearoff=0)
self.filemenu.add_command(label="Hello!", command=hello)
self.filemenu.add_command(label="Quit!", command=self.quit)
def __init__(self, master):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
self.config(menu=self.menuBar)
if __name__ == "__main__":
root = Tk()
ui = Application(root)
ui.mainloop()
我在OSX10.8上使用Python3。为什么会出现未知选项错误?
menu
不是Frame
的有效配置选项。也许你是想从
Tk
继承?相关问题 更多 >
编程相关推荐