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

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.