How would I reset a checkbutton value?? Once I click a checkbutton it retains an ON value of 1. How would I change it if i click the button off??
#!/usr/bin/perl use strict; #use diagnostics; use Tk; use Tk::Checkbox; #my $netUp = qx(bash /home/anthony/Documents/Bash/network); my $mw = MainWindow->new; $mw->geometry("150x600"); $mw->title("ConMan"); 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 ) { $checkButton = $mw->Checkbutton( -text => "$n", -onvalue => 1, -offvalue => 0, -command => sub{push +(@Sel, $n);}, -variable => \$Selec +ted[$i], )->pack( -side => 'top', + -anchor => 'nw' ); $i=$i+1; } my $connButton = $mw->Button( -text => "Connect", -command => \&value )->pack( -side = +> 'left', -ancho +r => 'sw', -padx +=> '5', -pady +=> '5' ); my $CancelButtons = $mw->Button( -text => "Close", -command => sub { print "Closing out Con +nMan.\n"; $mw->withdraw; exit 0; }, )->pack( -side => 'right', + -anchor => 'se', + -padx => '5',); sub value { my $p = scalar(@Sel); foreach my $x (@Sel) { if( ( $p ne 0 ) && ( $p lt 2) ) { print $x; return 0; } else { print "\nSelect one network please.\n"; return 0; } } print "\n"; } sub reset { } MainLoop;
In reply to reset checkbutton value by amboxer21
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |