Chinaunix
标题:
烦帮忙测试一段代码,在linux 64位下运行报错。
[打印本页]
作者:
hejianbu437
时间:
2014-01-06 16:43
标题:
烦帮忙测试一段代码,在linux 64位下运行报错。
烦帮忙测试下下面的代码,我在我的linux虚拟机上测试报错,在windows平台下,active-perl中运行可以正常。
use Tkx;
my $mw = Tkx::widget->new(".");
$mw->g_wm_title("Feet to Meters");
my $frm = $mw->new_ttk__frame(-padding => "3 3 12 12");
$frm->g_grid(-column => 0, -row => 0, -sticky => "nwes");
$mw->g_grid_columnconfigure(0, -weight => 1);
$mw->g_grid_rowconfigure(0, -weight => 1);
my $ef = $frm->new_ttk__entry(-width => 7, -textvariable => \$feet);
$ef->g_grid(-column => 2, -row => 1, -sticky => "we");
my $em = $frm->new_ttk__label(-textvariable => \$meters);
$em->g_grid(-column => 2, -row => 2, -sticky => "we");
my $cb = $frm->new_ttk__button(-text => "Calculate", -command => sub {calculate();});
$cb->g_grid(-column => 3, -row => 3, -sticky => "w");
$frm->new_ttk__label(-text => "feet")->g_grid(-column => 3, -row => 1, -sticky => "w");
$frm->new_ttk__label(-text => "is equivalent to")->g_grid(-column => 1, -row => 2, -sticky => "e");
$frm->new_ttk__label(-text => "meters")->g_grid(-column => 3, -row => 2, -sticky => "w");
foreach (Tkx::SplitList($frm->g_winfo_children)) {
Tkx::grid_configure($_, -padx => 5, -pady => 5);
}
$ef->g_focus;
$mw->g_bind("<Return>", sub {calculate();});
sub calculate {
$meters = int(0.3048*$feet*10000.0+.5)/10000.0 || '';
}
Tkx::MainLoop();
复制代码
我在我的linux下运行报错如下:
[root@localhost TK]# perl 1.pl
invalid command name "ttk::frame" at 1.pl line 8.
我的perl版本:
[root@localhost TK]# perl -v
This is perl 5, version 16, subversion 1 (v5.16.1) built for x86_64-linux-thread-multi
Tkx版本:
Tkx is up to date (1.09).
作者:
zhlong8
时间:
2014-01-06 16:53
本帖最后由 zhlong8 于 2014-01-06 16:54 编辑
查下虚拟机里TCL的版本,ttk 应该是 8.5 才有的
作者:
hejianbu437
时间:
2014-01-06 17:17
回复
2#
zhlong8
是指下面的的模块吗?
下面是我机器上关于tcl的模块:
***************************************
Tcl -- 1.02
***************************************
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/x86_64-linux-thread-multi
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/x86_64-linux-thread-multi/auto/Tcl
/home/hjb/perl.v5.16.2/man/man3
***************************************
Tcl::pTk -- 0.85
***************************************
/home/hjb/perl.v5.16.2/bin
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk/DragDrop
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk/Menu
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk/TableMatrix
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk/Tie
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk/demos/images
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk/demos/widget_lib
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk/demos/widtrib
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk/demos/widtrib/lib/npuz
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/Tcl/pTk/images
/home/hjb/perl.v5.16.2/lib/site_perl/5.16.1/auto/Tcl/pTk/TextEdit
/home/hjb/perl.v5.16.2/man/man1
/home/hjb/perl.v5.16.2/man/man3
复制代码
作者:
zhlong8
时间:
2014-01-06 19:40
回复
3#
hejianbu437
我指的是 TCL 编程语言的解释器版本
作者:
hejianbu437
时间:
2014-01-07 09:33
回复
4#
zhlong8
应该是如下的版本,确实不是8.4版本的。
[root@localhost ~]# rpm -qa | grep tcl
tclx-8.4.0-5.fc6
tcl-8.4.13-4.el5
[root@localhost ~]#
作者:
zhlong8
时间:
2014-01-07 11:40
回复
5#
hejianbu437
ttk 是 8.5 才加入 tcl/tk 的所以 8.4 没这个功能,你把你代码中 ttk 那部分去掉用就可以了,按命名规则应该就是 ->new_frame(...) 这样吧
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2