Python 2.7 Tkinter ttk 2.7 32位(osx 10.10.x)

Python 2.7 Tkinter ttk 2.7 32位(osx 10.10.x),python-2.7,tkinter,osx-yosemite,ttk,Python 2.7,Tkinter,Osx Yosemite,Ttk,今天我试着学习Tkinter下面的内容,但在“退出按钮”部分我发现了一些问题。。。我将在此处粘贴代码: #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode Tkinter tutorial This program creates a quit button. When we press the button, the application terminates. author: Jan Bodnar last modified: De

今天我试着学习Tkinter下面的内容,但在“退出按钮”部分我发现了一些问题。。。我将在此处粘贴代码:

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
ZetCode Tkinter tutorial
This program creates a quit
button. When we press the button,
the application terminates. 
author: Jan Bodnar
last modified: December 2010
website: www.zetcode.com
"""
from Tkinter import *
from ttk import *

class Example(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)   
        self.parent = parent
        self.initUI()
    def initUI(self):
        self.parent.title("Quit button")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)
        quitButton = Button(self, text="Quit",command=self.quit)
        quitButton.place(x=50, y=50)

def main():
    root = Tk()
    root.geometry("250x150+300+300")
    app = Example(root)
    root.mainloop()  

if __name__ == '__main__':
    main()  
运行它会导致此错误

 File "/Users/mazzalex02/Desktop/provatk2.py", line 51, in <module>
    main()
  File "/Users/mazzalex02/Desktop/provatk2.py", line 46, in main
    app = Example(root)
  File "/Users/mazzalex02/Desktop/provatk2.py", line 23, in __init__
    Frame.__init__(self, parent)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/ttk.py", line 738, in __init__
    Widget.__init__(self, master, "ttk::frame", kw)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/ttk.py", line 554, in __init__
    _load_tile(master)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/ttk.py", line 46, in _load_tile
    master.tk.eval('package require tile') # TclError may be raised here
TclError: can't find package tile
/Users/mazzalex02/Downloads/tcltk/tk8.4.20/unix/../generic/tk.h:22:3: error: Tk 8.4 must be compiled with tcl.h from Tcl
      8.4
#       error Tk 8.4 must be compiled with tcl.h from Tcl 8.4
        ^
/Users/mazzalex02/Downloads/tcltk/tk8.4.20/unix/../generic/tk3d.c:1353:13: warning: assigning to 'Tcl_ObjType *'
      (aka 'struct Tcl_ObjType *') from 'const Tcl_ObjType *' (aka 'const struct Tcl_ObjType *') discards qualifiers
      [-Wincompatible-pointer-types-discards-qualifiers]
    typePtr = objPtr->typePtr;
            ^ ~~~~~~~~~~~~~~~
1 warning and 1 error generated.
make[3]: *** [tk3d.o] Error 1
make[2]: *** [build-tk] Error 2
make[1]: *** [tk] Error 2
make: *** [develop] Error 2

看起来Tkinter不知道您有8.6 Tcl版本。可以肯定的是,将print TkVersion添加到脚本或打开/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/ttk.pyAdding
print TkVersion
prints
8.4
,而我以为我安装了8.6.x……那么问题就来了,这是我如何让Tkinter认识到我在google上搜索时有ActiveTcl 8.6…第8个链接:os x安装Tkinter 8.6