- 论坛徽章:
- 0
|
本帖最后由 pcbfans 于 2012-06-11 22:00 编辑
my %section = (
A => [1,2,3],
B => [4,5,6],
C => [7,8,9],
);
... ...
for my $par_tmp (@{ $section{$sect_name} }) {
$f->Button(
-text => "$par_tmp",
-relief => 'ridge',
-bg => '#8189ce14cf5b',
-fg => 'black',
-command => \&sub_program,
)->pack(qw/-side top -fill x -padx 4 /);
}
push @frames,$f;
push @button,$b;
}
$FRAME_L->Button(
-text => "CLOSE",
-relief => 'sunken',
-borderwidth => 1,
-bg => "white",
-fg => "black",
-command => sub { exit; },
)->pack(qw/-side bottom -fill x -padx 1 -pady 2 /);
sub sub_program{
print "sub program!";
}
MainLoop;
按A栏下面的每个按钮都会输出sub program!
问题是: 如何分别为A栏,B栏,C栏下面的按钮[1,2,3]定义子程序?能否在这个例子上给出代码以便借鉴。 |
|