包需要 Tk - 在 tclsh 中不起作用
我正在尝试在 tclsh 中加载 Tk 包,但无法加载它。经过谷歌搜索后,我认为修改 auto_path 可能会有所帮助。但不幸的是它对我没有帮助。
在我的 Linux 机器上,我可以运行 tclsh 和 Wish,两者都是 v8.3;以下是我在 tclsh 上尝试过的内容并希望:
% tclsh
% package require Tk
can't find package Tk
% puts $auto_path
/usr/share/tcl8.3 /usr/share /usr/lib
%
% wish
% puts $auto_path
/usr/share/tcl8.3 /usr/share /usr/lib /usr/share/tk8.3
%
% tclsh
% lappend auto_path /usr/share/tk8.3
/usr/share/tcl8.3 /usr/share /usr/lib /usr/share/tk8.3
% package require Tk
can't find package Tk
%
有人可以帮我解决这个问题吗?
编辑: 我尝试了以下方法来使其正常工作。但一定有更好的方法
% tclsh
% load /usr/lib/libtk8.3.so
% package require Tk
8.3
I am trying to load Tk package in tclsh but I am not able to load it. After googling, I figured that modifying auto_path might help. But unfortunately it did not help me.
In my Linux machine I can run tclsh and wish and both are v8.3; The following is what I tried on tclsh and wish:
% tclsh
% package require Tk
can't find package Tk
% puts $auto_path
/usr/share/tcl8.3 /usr/share /usr/lib
%
% wish
% puts $auto_path
/usr/share/tcl8.3 /usr/share /usr/lib /usr/share/tk8.3
%
% tclsh
% lappend auto_path /usr/share/tk8.3
/usr/share/tcl8.3 /usr/share /usr/lib /usr/share/tk8.3
% package require Tk
can't find package Tk
%
Can someone help me in fixing this problem?
EDIT:
I tried the following to get it working. But there must be a better way
% tclsh
% load /usr/lib/libtk8.3.so
% package require Tk
8.3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
8.3 不支持将 Tk 作为标准包加载(无论如何现在基本上不支持;最后一个 8.3 版本大约是 10 年前)。升级到 8.5 应该就可以了;它也可能在 8.4 中工作(但现在也已经结束了)。
(有很多原因导致它在 8.3 中不起作用;基本上,它需要添加额外的 API 函数(在 8.4 中完成),并且需要以正确的方式完成构建。这也在 8.4 中完成.)
Loading Tk as a standard package is not supported in 8.3 (which is basically unsupported now anyway; the last 8.3 release was about 10 years ago). Upgrading to 8.5 should make it all work; it might also work in 8.4 (but that's also end-of-lifed now).
(There's a whole bunch of reasons why it didn't work in 8.3; basically, it required extra API functions to be added – done in 8.4 – and it required the build to be done in the right way. That was done in 8.4 too.)