Monkless has asked for the wisdom of the Perl Monks concerning the following question:
Monks, I once again stand before you asking to be blessed with the great wisdom you posses!
I am creating A menubutton which when clicked produces the checkbutton menu. Now everything works like a charm, with the exception of the end desired result. See code below:
$b4 = $windows{overlord_left1}->Menubutton( -text => 'EC', -takefocus => 0, -background=>'black', -foreground=>'white', -relief => 'flat'); for $label(@ECs){ my $i=0; $i++; my $variable_name = "$label"."$i"; $label_ref = \$variable_name; chomp $label; $b4->checkbutton(-label => "$label", -variable => $label_ref, -command => sub { if ($variable_name > 0){ our $ec = "$label";}}); if($ec){ foreach (@systemSelected){ push @systemNames, "$_"."-$ec";} }
I am having to use a variable reference, as I have to somehow dynamically create the variable used for the checkbutton variable. Now this works except when I check more than 1 box. If only one checkbox is selected then the name is appended as expected, but if I select multiple checkboxes, I only get the output of ONE button :s Assuming this is a result of my dynamic variable, any suggestions otherwise?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl/Tk - Dynamic Checkbuttons?
by zentara (Cardinal) on Mar 29, 2012 at 15:20 UTC | |
|
Re: Perl/Tk - Dynamic Checkbuttons?
by ~~David~~ (Hermit) on Mar 29, 2012 at 14:05 UTC |