Or you could use the -command option to pass arguments to a named subroutine. TMTOWTDI. Also note how $i is used as the loop variable.
... my @buttons; for my $i (0..5){ push @buttons, $mw->Button( -text => $row[$i], -command => [ \&buttonpress, $row[$i] ], )->pack; } sub buttonpress{ my $btn = shift; print "button $btn pressed\n"; }
In reply to Re: Perl/TK get the Button's text
by hangon
in thread Perl/TK get the Button's text
by Aboveyou
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |