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?


In reply to Perl/Tk - Dynamic Checkbuttons? by Monkless

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.