_tkinter TclError:找不到软件包Tix [英] _tkinter TclError: can't find package Tix

查看:859
本文介绍了_tkinter TclError:找不到软件包Tix的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个朋友给我发送了一些Tkinter/Tix代码,但这是针对Python 2的:

A friend sent me some Tkinter/Tix code, but it was for Python 2:

from Tkinter import * 
import Tix
import ScrolledText   

我有Python 3,没有安装Tix,并且程序崩溃.经过一番搜索后,我将代码更改为:

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

我想知道如何正确修改代码以使其运行以及如何安装Tix.

I would like to know how to modify the code correctly to make it run and how to install Tix.

完整代码的原始形式: http://pastebin.com/JCqhNSRR

The whole code in original form: http://pastebin.com/JCqhNSRR

推荐答案

我已经在此处(Ubuntu 12.04.5)测试了此问题,并遇到了相同的错误.在Web上浏览发现关于此功能错误的辩论.这是我找到解决方案的转录部分:

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:

我在Ubuntu 13.04上,当我看到此错误时,我安装了tix-dev软件包,并且一切正常.我相信它在OSX上同样简单,但我对此一无所知.另外,请确保您正在运行Python 3.3,因为这是我正在开发/测试/使用GUI的唯一版本.

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.

我安装了tix-dev(apt-get install tix-dev),并且已经通过Python 2.7.3和Python 3.2.3进行了测试,并且可以正常工作.

I installed tix-dev (apt-get install tix-dev) and have tested with Python 2.7.3 and Python 3.2.3 and works.

Python 3.3.3 中导入tkinter和在 OSX 10.9.5 2.7.5 中导入Tix的测试都存在相同的问题使用 ActiveTcl 8.6.3.1 使用Ubuntu.

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.

问题出在 Tcl lib Tix 上.解决方案是使用64位支持重新编译lib.

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

要确保将其编译为64位平台,请运行以下命令

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

编译后,将 libTix8.4.3.dylib 复制到 Tcl/Tk 软件包安装的libTix路径.

After compile, copy the libTix8.4.3.dylib to path of libTix were installed by Tcl/Tk package.

通常路径是/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()
>>> 

这篇关于_tkinter TclError:找不到软件包Tix的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆