【发布时间】:2014-04-02 12:40:33
【问题描述】:
我不断收到错误:
_tkinter.TclError: 未知选项“-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()
我在 OS X 10.8 上使用 python 3。为什么会出现未知选项错误?
【问题讨论】:
标签: python python-3.x tkinter