找回密码
 注册
查看: 4912|回复: 3

生成对话框perl程序

[复制链接]
发表于 2010-5-9 08:50:10 | 显示全部楼层 |阅读模式
#!usr/bin/perl
# listbox.pluse warnings;
use strict;
use Tk;
my $status = 'Your favorite color is not yet entered';
my @colors =qw(Red Green Orange White Yellow Purple Blue Black);
my $mw = MainWindow->new;$mw->title('Listbox Example');
my $label = $mw->Label(-textvariable => \$status);
my $enter = $mw->Label(-text => 'Enter your favorite color(s)');
my $lb = $mw->Listbox(-selectmode => 'multiple');$lb->insert('end', sort @colors);
my $show = $mw->Button(-text => 'Show selections', -command => [\&display]);
my $exit = $mw->Button(-text => 'Exit', -command => [$mw => 'destroy']);
$label->pack;
$enter->pack;
$lb->pack;
$show->pack;
$exit->pack;
MainLoop;
sub display {
my @selections = $lb->curselection;
   $status = "You selected: \n";
   foreach (@selections) {
      $status .= $lb->get($_) . "\n";
   }
   $lb->selectionClear(0, 'end');
}

回复

使用道具 举报

发表于 2011-10-30 22:08:36 | 显示全部楼层
perl  TK  厉害  有空试试
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-24 20:18 , Processed in 0.029095 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表