A friend sent me some Tkinter/Tix code, but it was for Python 2:
from Tkinter import * import Tix import ScrolledText
I have Python 3, I have no Tix
installed, and program crashes. After some searching I’ve changed the code to:
from tkinter import * from tkinter import tix from tkinter import scrolledtext
Thats what I found on the internet. I have no idea if this is a right approach. But code still does no run it crashes on
root = tix.Tk() File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/tix.py, line 221, in __init__ self.tk.eval('package require Tix') _tkinter.TclError: can't find package Tix
I would like to know how to modify the code correctly to make it run and how to install Tix
.
The whole code in original form: http://pastebin.com/JCqhNSRR
Advertisement
Answer
I’ve tested this issue here (Ubuntu 12.04.5) and have got same error. Browsing over web found a debate about this feature’s error. Here’s a transcription part where I found the solution:
I am on Ubuntu 13.04 and when I see this error, I install tix-dev package and everything just works. I’d believe its similarly simple on OSX, but I have no clue about it. Also, make sure you’re running Python 3.3 as that’s the only version I’m developing/testing/using the GUI with.
I installed tix-dev
(apt-get install tix-dev
) and have tested with Python 2.7.3 and Python 3.2.3 and works.
Tests importing tkinter
in Python 3.3.3 and Tix
in 2.7.5 in OSX 10.9.5 have same issues with Ubuntu using ActiveTcl 8.6.3.1.
The problem is with Tcl lib Tix. The solution is to recompile the lib with 64 bit support.
The flags I used to compile were:
$ ./configure --enable-64bit --enable-threads --enable-framework --enable-aqua --enable-corefoundation
To enssure the were compiled to 64 bits platform run the following command
$ lipo -info libTix8.4.3.dylib Non-fat file: libTix8.4.3.dylib is architecture: x86_64
After compile, copy the libTix8.4.3.dylib to path of libTix were installed by Tcl/Tk package.
Usually the path is /Library/Tcl/teapot/package/macosx10.5-i386-x86_64/lib/Tix8.4.3/libTix8.4.3.dylib
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from tkinter import tix >>> root = tix.Tk() >>>