GayathriBalu has asked for the wisdom of the Perl Monks concerning the following question:
hi all, i want to create an array of buttons and handle them when clicked. in my code the last button in the array is handled even if any other button is clicked. pls help. thanks
my @buttons; for my $i(0..5){ push @buttons, $mw->Button(-text => $i, -command => sub{ print "pressed $i\n"; # or use the widget: print "pressed ", $buttons[$i]->cget('-text'), "\n"; })->pack; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Array of buttons
by choroba (Cardinal) on Oct 22, 2014 at 11:55 UTC | |
Re: Array of buttons
by ww (Archbishop) on Oct 22, 2014 at 13:42 UTC | |
Re: Array of buttons
by glenn (Scribe) on Oct 22, 2014 at 13:53 UTC |
Back to
Seekers of Perl Wisdom