0

today i tried to learn Tkinter following this guide, but at the "Quit button" section i found some problems... I will paste the code here:

#!/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()  

Running it gives this error

 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

I really don't know what to do, since i installed ActiveTcl (8.6.x)... It seems like it needs tile but i read it is old and surpassed by ttk...

EDIT: installed active tcl 8.5.x, reinstalled python 2.7, but the error is still there. I found this page and i thought i could get past the error but following the readme coming with tk8.4.20 (drive.google.com/file/d/0B2pedtcO2MfOdkpsWFFlYXVUcVU/view?usp=sharing sorry, i can't add more than two hyperlinks with the reputation i have got) brought me to this error

/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
Ale
  • 87
  • 1
  • 13

0 Answers0