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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |