goutham has asked for the wisdom of the Perl Monks concerning the following question:

Why do all my radio buttons getting selected by default? I just need to select them only when i click on it with my mouse.

$main2=MainWindow->new(); $main2->geometry("300x300"); $main2->title("Test Selection "); $main2->Label(-text=>"Select the test ")->pack(); $main2->Radiobutton(-text=>"Production line ( For plotting one instrum +ent) ",)->pack(); $main2->Radiobutton(-text=>"Pilot Phase ( For plotting multiple instru +ments) ",)->pack(); $main2->Button(-text => "OK",-command => [\&paramsel])->pack();

Replies are listed 'Best First'.
Re: All Radio Buttons selected by default?
by Discipulus (Canon) on Jun 18, 2015 at 19:01 UTC
    i think is a default behaviour if, as i only can guess, in the real script the button is binded is bound to a variable that holds a true value. Your use is more similar to a CheckButton not a Radiobuttom. The inteded use of a Radiobutton is similar to:
    my $dot_after = 2; .. my $fr2 = $scrolled_top->Frame(-borderwidth => 2, -relief => 'groove') +->pack(-side=>'top',-anchor=>'w',-pady=>5); $fr2->Label(-text => "Numbers as dot if ")->pack(-side => 'left',-ex +pand => 1); $fr2->Radiobutton(-text => "1",-variable => \$dot_after, -value=>'1' +)->pack(); $fr2->Radiobutton(-text => "2",-variable => \$dot_after, -value=>'2' +)->pack(); $fr2->Radiobutton(-text => "3",-variable => \$dot_after, -value=>'3' +)->pack(); $fr2->Radiobutton(-text => "4",-variable => \$dot_after, -value=>'4' +)->pack(); $fr2->Radiobutton(-text => "never",-variable => \$dot_after, -value= +>'9999')->pack();

    HtH
    L*

    Update:typo (en-BAD) fixed,thanks MidLifeXis
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      Thank you Discipulus
Re: All Radio Buttons selected by default?
by kcott (Archbishop) on Jun 18, 2015 at 19:03 UTC

    G'day goutham,

    I provided you with a link to Tk::Radiobutton in the CB. Given you just immediately posted your code here, you clearly didn't read this documentation.

    You have no -variable or -value options set. The documentation will tell you about those: I can't read it for you!

    -- Ken

Re: All Radio Buttons selected by default?
by Aldebaran (Curate) on Jun 19, 2015 at 00:58 UTC

    Hi goutham,

    I've been banging my head against the wall of trying to get radio buttons selected and pressed and found the methods on this thread to be most helpful: <Re^2: click radio button with WWW::Mechanize The title should be "click radio button with WWW::Mechanize."/p>

    Best of luck,

      Tk not related to WWW::Mechanize :)