2010-11-22 138 views
2

运行我编写的python/tkinter GUI应用程序时出现以下错误。_tkinter.TclError:无效的命令名称“labelframe”

我以为它可能是一个Tcl/Tk版本问题,但LabelFrame()命令是在Tcl/Tk 8.4(这是我使用的版本)中添加的。

我正在尝试执行该程序的另一台计算机能够运行我编写的另一个python/tkinter应用程序 - 应用程序之间的差异在于一个使用了LabelFrame()小部件,另一个不使用。

Traceback (most recent call last): 
    File "/home/nharris/python/isub_parser/isub.py", line 672, in <module> 
    timeFrame = LabelFrame(optFrame, text="Time Scale Options") 
    File "/usr/apps/Python/python2.6.1-rhel3-i686/lib/python2.6/lib-tk/Tkinter.py", line 3525, in __init__ 
    Widget.__init__(self, master, 'labelframe', cnf, kw) 
    File "/usr/apps/Python/python2.6.1-rhel3-i686/lib/python2.6/lib-tk/Tkinter.py", line 1932, in __init__ 
    (widgetName, self._w) + extra + self._options(cnf)) 
_tkinter.TclError: invalid command name "labelframe" 
+1

'import Tkinter的输出是什么; print Tkinter.TkVersion` – SingleNegationElimination 2010-11-22 21:45:46

回答

2

python可能会使用自己的特殊版本的TCL/TK,具体取决于它的构建和安装方式。这通常是在Windows上的情况,有时在Linux上是这种情况,在MacOS X上很少出现这种情况。您必须依靠python内部报告的版本来知道它使用的是哪个版本。

如果python没有使用已安装的版本(正如您遇到的情况),您可以尝试更新python。如果在你的linux发行版中,你无法克服使用可用软件包构建python的方式,你必须从源代码构建python以使用更新版本的TCL/TK或使用已安装的版本。

1

很可能得到两个不同版本的Tcl/Tk的使用这两种方法报道:

Method 1: 
>tclsh 
%info patchlevel 
8.4.15 

Method 2: 
>python 
>>>import Tkinter;print Tkinter.TkVersion 
8.3 

Key: 
> default command line 
>>> python command line 
% tcl command line 

的Tcl/Tk的更新应该修复它。