我正在使用由kmx实现的 Perl IUP 模块,我喜欢它,因为它易于使用并且看起来还不错。
我需要从列表中创建一个带有多个按钮的框架框(比如说 40-50)。我可以在遍历数组的 for 循环中轻松创建它(双数组,每行包含“名称”和值)`
my @ChildsSetOfButtons=();
foreach $array (@ITEMNAME)
{
$tempButton = IUP::Button->new( TITLE=>$array->[2],
SIZE=>"50x20", FONTSTYLE=>'bold',FONTSIZE=>"10");
$tempButton->ACTION( sub {selOrder($array->[3]); });
}
push(@ChildsSetOfButtons,$tempButton);
my $tableOfButton = IUP::Frame->new( TITLE=>"Items",child=>
IUP::GridBox->new( child=> [@ChildsSetOfButtons], NUMDIV=>4,
ORIENTATION=>"HORIZONTAL"), MARGIN=>"5x5",
EXPANDCHILDREN =>"YES",GAPLIN=>10, GAPCOL=>10);
好吧,按钮以漂亮的网格精美地出现在 GUI 中。现在我的问题是,如何从每个 Button 操作中发送单独的唯一值?我了解这些值在创建按钮时是静态链接的。
但不知何故,这个类似的实现我可以让它在 PerlTK 中工作,因为我从这个 IUP 开始,我不想回到 TKperl 并从头开始编写我的整个 GUI。`
foreach my $array (@ITEMNAME)
{
$fr2->Button(-text=>$array->[2],
-padx => 6,
-font => ['arial', '10', 'normal'],
-foreground => 'blue',
-command => [\&writeUARTDirect,$array->[3]],
)->pack(-side=>'bottom');
}
` 我怎样才能让它在 perl-IUP 框架中工作?谁能告诉我一个窍门?:)