2016-09-26 2 views
-2

나는 파이썬 Tkinter를 배우고하지만 난 그것을 컴파일하려고 할 때마다 나는 오류가 있습니다"_tkinter.TclError : 알 수없는 옵션"을 해결하는 방법?

Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
File "/usr/lib/python2.7/dist-packages/spyderlib/ 
widgets/externalshell/sitecustomize.py", line 540, in runfile 
execfile(filename, namespace) 
File "/home/jason/.spyder2/.temp.py", line 14, in <module> 
menu.config(menu=menu) 
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1274, 
inconfigure 
return self._configure('configure', cnf, kw) 
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1265, 
in _configure 
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) 
_tkinter.TclError: unknown option "-menu"). 

내 코드는 다음과 같습니다

from tkinter import * 

def hello(): 
    print "hello"  

root = Tk() 
menu = Menu(root) 
menu.config(menu=menu) 
menu.add_command(label ="new",command = hello) 

root.mainloop() 

답변

0

당신은 당신의 코드에 약간의 문제가 있습니다. menu.config 대신 root.config을 사용하면 이러한 오류가 발생하지 않습니다.

자세한 내용 및 자세한 자습서는 Tkinter Menu Widget을 참조하십시오.

관련 문제