Tkinter._test() _tkinter.TclError错误
在Linux Redhat 6上,我从源代码编译并安装了python2.7,这样就不会影响系统自带的python版本2.66。
我们有一些脚本使用了tkinter这个库,所以我进行了测试,但测试失败了。我在远程系统上看到了弹出窗口,但这个窗口是空的,没有任何文字或按钮显示出来。
Python 2.7.6 (default, Aug 21 2014, 16:37:19)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>> Tkinter._test()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/local/lib/python2.7/lib-tk/Tkinter.py", line 3778, in _test
label = Label(root, text=text)
File "/home/local/lib/python2.7/lib-tk/Tkinter.py", line 2537, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "/home/local/lib/python2.7/lib-tk/Tkinter.py", line 2036, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError
1 个回答
1
Tkinter._test()
是用来检查一切是否正常的。
通常,如果出现错误,说明 tkinter 没有正确安装。这时候你需要重新安装 Python。另外,确保你没有随便修改模块的代码,这也可能会导致问题。总之,就是重新安装一下。