Thank you AppleFritter.
Where exactly did I go wrong? Could you explain please? I had a look at the doc and seen that deselect would deselect the checkbuttons but I tried and no luck. I guess I was selecting the wrong element to reference.



I see what made the difference was the button sub.

my $connButton = $mw->Button( -text => "Connect", -command => sub { my @networks = grep { defined } @checkbox; if(@networks == 1) { say $networks[0]; } else { say "Select one network, please."; } }

I didn't post with the original code, at least I dont think but here was my version of the checkbutton function. Essentially the same as yours.



open my $FILE, '<', "ESSID", or die "Can't open file: $!"; my @lines = <$FILE>; my @Sel; my $i = 0; my @Selected; my $checkButton; foreach my $n ( @lines ) { chomp $n; $checkButton = $mw->Checkbutton( -text => "$n", -onvalue => 1, -offvalue => 0, -command => sub{push +(@Sel, $n)} && sub{ $Selected[$i] = defined $Selected[$i] ? undef : $ +n;}, -variable => \$Selec +ted[$i], )->pack( -side => 'top', + -anchor => 'nw' ); $i=$i+1; }

In reply to Re^2: reset checkbutton value by amboxer21
in thread reset checkbutton value by amboxer21

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.