Perl/Tk会者不难,难者不会的设置问题
小弟在Cygwin中安装perl/tk,安装过程没有出现错误.
用以下代码测试:
#!/usr/bin/perl
use Tk;
my $window = MainWindow->new;
$window->title("Host Access Report");
($lab = $window->Label(-text => "Results go here"))->pack;
$window->Entry(-textvariable => \$nnn )->pack;
$window->Button(-text => "Go", -command => \&but )->pack;
$window->Button(-text => "This is the quit button ", -command => \&finito )->pack;
MainLoop;
解释器报告错误:
couldn't connect to display ":0" at /usr/lib/perl5/vendor_perl/5.8/cygwin/Tk/Mai
nWindow.pm line 55.
MainWindow->new() at tk.pl line 5
在Google上go一把,找到很多english的解释(可惜没有看懂)
I think that is not a problem with your script,
but with the environment variable DISPLAY that
may be set incorrectly. Or if you are running that
script from a session window that doesn't let
graphics (spawning windows) though, that is another
possibility.
Are you running your script from your local host
or telnet'ed / rsh'ed ?
看不明白...希望有大虾赐教........................................
问题点数:100、回复次数:12Top
1 楼michael_g_hu(一代风云)回复于 2006-04-24 16:24:58 得分 0
TK 用过,不过是python 的Top
2 楼xyzxyz1111(程序员的自我修养)回复于 2006-04-24 16:26:02 得分 0
set DISPLAY="127.0.0.1:0.0"
另外,你是否安装在 cygwin上了XFree86?Top
3 楼DelphiNew(沙鼠)回复于 2006-04-26 14:34:55 得分 0
cygwin的Tk默认要连接一个X-server。。所以,在cygwin-Xorg中运行就好了。Top
4 楼logo0775(兩年啦,還沒有得到一分,誰給一點點嘛∶)coder)回复于 2006-05-11 16:14:11 得分 0
E:\1>perl tk.pl
Global symbol "$lab" requires explicit package name at tk.pl line 9.
Global symbol "$nnn" requires explicit package name at tk.pl line 10.
Execution of tk.pl aborted due to compilation errors.
Top
5 楼logo0775(兩年啦,還沒有得到一分,誰給一點點嘛∶)coder)回复于 2006-05-11 16:15:17 得分 0
#!/usr/bin/perl -w
use strict;
use Tk;
require Tk::BrowseEntry;
my $window = MainWindow->new;
$window->title("Host Access Report");
(my $lab = $window->Label(-text => "Results go here"))->pack;
$window->Entry(-textvariable => \my $nnn )->pack;
$window->Button(-text => "Go", -command => \&but )->pack;
$window->Button(-text => "This is the quit button ", -command => \&finito )->pack;
MainLoop;Top
6 楼logo0775(兩年啦,還沒有得到一分,誰給一點點嘛∶)coder)回复于 2006-05-11 16:16:07 得分 0
沒問題....Top
7 楼tingyunsz(听雨)回复于 2006-05-22 13:45:00 得分 0
perl 5.8 for win,已经自带tk了.Top
8 楼luodi(无知者无畏)回复于 2006-08-05 15:36:36 得分 0
用 ActiveState 公司的 activeperl 就好了,不用装什么 cygwin,perl/tk程序也直接可以运行,并不用考虑X server的问题Top
9 楼hanfa(平子)回复于 2006-11-06 15:20:54 得分 0
Windows 下直接运行就行了(Perl 5.6.1)Top
10 楼iambic()回复于 2006-11-06 17:05:25 得分 0
记得旧版本的Cygwin好像是没有X-Server的。Top
11 楼xxyyboy(壮志凌云)(★★★★★)回复于 2006-11-16 09:44:29 得分 0
I think that is not a problem with your script,
but with the environment variable DISPLAY that
may be set incorrectly. Or if you are running that
script from a session window that doesn't let
graphics (spawning windows) though, that is another
possibility.
翻译:我认为这不是脚本的问题,环境变量 DISPLAY可能设置的不正确,也有可能你运行脚本的时候,你的session中不允许调用图形界面。Top
12 楼sm4llb0y()回复于 2006-12-02 22:52:09 得分 0
没必要装Cygwin,如果要在windows平台上编写漏洞溢出程序还值得考虑,不过最新的ActivePerl中已经集成了Tcl/Tk的模块!感觉相当不错!呵呵!Top




