0

如何将打印输出发送到 perl/tk 列表框,可以有无限的打印行。我知道如何创建列表框,但现在不知道如何调用列表框并打印到它。这是逐行生成打印的代码。

  [code]
    #!/usr/bin/perl -w
    use strict;

     #Read input file a line at a time

      $mydelimiter=",";



       open (INPUT1,"$INFILE1") or
         die " cannot open $INFILE1";

       while (<INPUT1>) { 
    @INFILE = ($_);
    chomp($_);
    @FAILS = split (/,/,);
    @SERVER = splice (@FAILS,0,1);
    @TYPE = splice (@FAILS,0,1);
    @REASON = splice (@FAILS,0,1);
    @STATUS = splice (@FAILS,0,1);
    @TICKET = splice (@FAILS,0,1);
    @RESOLUTION = splice (@FAILS,0,1);
    foreach $server1 (@SERVER) {
        $servers = $server1;
        $servers =~ tr/[a-z]/[A-Z]/;
    }   

    foreach $type1 (@TYPE) {
        $types = $type1;
        $types =~ tr/[a-z]/[A-Z]/;
    }   

    if ( "$types" eq "F") {
    $types="FAILED";
    }
    else {
    if ("$types" eq "S") {
    $types="FILES";
    @TICKET="TICKET";
    }}

    $value= &read_location;
    if ("$value" ne "0"){
    print "@SERVER \n";
    }
        [code]
4

1 回答 1

0

这是使用列表框的示例 perl/tk 脚本

#!/usr/bin/perl

use strict;
use warnings;
use Tk;


my $win = new MainWindow;
$win->geometry("400x300");

my $listbox = $win->Scrolled("Listbox", -scrollbars => 'se')
->pack(-expand => 1, -fill => 'both');

my @array = qw/hello there world/;
$listbox->insert('end', @array);

#or
for(@array){
    $listbox->insert('end', $_); #for single elements, note it appends to the listbox
}
MainLoop;

这是使用 perl/tk 继续研究和信息的好资源

http://docstore.mik.ua/orelly/perl3/tk/index.htm

于 2014-05-06T03:01:46.473 回答