Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

if click radio button not working separatly?

by virudinesh (Acolyte)
on Apr 30, 2013 at 07:50 UTC ( #1031345=perlquestion: print w/ replies, xml ) Need Help??
virudinesh has asked for the wisdom of the Perl Monks concerning the following question:

use Tk; my $mw = new MainWindow(-background=>'Gray'); $mw->geometry("1400x800"); $mw ->optionAdd('*background','Gray'); $wb[0] = $mw->Radiobutton( -variable => \$file, -command => \&toclink, -text => 'TOC LINK', -font => "r18", -width => 17, -foreground => 'black', -value => 1)->pack(-side=> 'top',-anchor=>'w',)->place(-relx =>0. +0,-rely =>0.20); $wb[1] = $mw->Radiobutton( -variable => \$file, -command => \&chapterlink, -text => 'CHAPTER LINK', -font => "r18", -width => 17, -foreground => 'black', -value => 2)->pack(-side=> 'top',-anchor=>'w',)->place(-relx =>0.0 +15,-rely =>0.25); $wb[2] = $mw->Radiobutton( -variable => \$file, -command => sub {$flag =3;}, -text => 'FIGURE LINK', -font => "r18", -width => 17, -foreground => 'black', -value => 3)->pack( -side => 'top', -anchor => 'w',)->place(-relx =>0.007, -rely =>0.30); MainLoop(); sub toclink() { #$wb[1]->deselect(); $frme_window = $mw ->delete(); if($file==0) { $mw->messageBox(-message => "Select Your Linking OPtionslll",-tit +le =>'MessageBox'); } elsif($file==1 and $file1==0) { $file1=1; $frm_name = $mw -> Frame(-background => 'DarkGray',-relief => 'sunken' +)->pack(-ipadx => 330,-ipady =>0, -side => "right", -fill => "y"); $frm_name->Label(-text =>"Do You Want Give Input Styles: ",-font => 'V +erdana 10 bold',-foreground => 'dark red',-background => 'DarkGray', +-height => 1,-width =>28) -> pack( )->place( -relx =>0.02, -rely =>0.08); $frm_name->Button(-foreground => 'dark red',-text => "yes",-font => ' +Verdana 8 bold', -height => 1,-width => 10,-background => 'DarkGray', +-command => \&enable) -> pack ( )->place( -relx =>0.43, -rely =>0.08); $frm_name->Button(-foreground => 'dark red',-text => "No",-font => 'V +erdana 8 bold', -height => 1,-width => 10,-background => 'DarkGray',- +command => \&disable) -> pack ( )->place( -relx =>0.57, -rely =>0.08); } } sub chapterlink() { #$wb[0]->deselect(); #$frm_name->$mw->delete(); if($file==0) { $mw->messageBox(-message => "Select Your Linking OPtionslll",-tit +le =>'MessageBox'); } elsif($file==2 and $file2==0) { $file2=2; $frme_window = $mw -> Frame(-background => 'DarkGray',-relief => 'sun +ken')->pack(-ipadx => 330,-ipady =>0, -side => "right", -fill => "y") +; $butn =$frme_window->Label(-text =>'CHAPTER LINK ',-font => 'Verdana +15 bold',-foreground => 'dark red', -background => 'DarkGray',-heigh +t => 1,-width =>23) -> pack( )->place( -relx =>0.3, -rely =>0.1); $labl = $frme_window->Label(-text =>"Chapter Files ",-font => 'Verdana + 10 bold',-foreground => 'dark red',-background => 'DarkGray',-heigh +t => 1,-width =>15) -> pack( )->place( -relx =>0.01, -rely =>0.30); $path_text6 = $frme_window->Entry(-textvariable => \$def_path1,-font = +> 'Verdana 8 bold',-width => 35,-background =>'white')->pack(-expand +=> 1)->place(-relx => 0.20, -rely => 0.3); $path_butn1 = $frme_window->Button(-foreground => 'dark red',-text = +> "Browse",-font => 'Verdana 8 bold', -height => 1,-width => 10,-comm +and => \&browsecl) -> pack ( )->place( -relx =>0.65, -rely =>0.3); $path_buttn2 = $frme_window->Button(-foreground => 'dark red',-text +=> "Submit",-font => 'Verdana 8 bold', -height => 1,-width => 10,-com +mand => \&submitcl) -> pack ( )->place( -relx =>0.80, -rely =>0.3); } } am correct previous my question. 1.all radio buttons contains same variable. 2.set value parameters is different value.like 1,2,3 3.all the variable used for clicking button but it was not working my output need for 1.if click toc link means only visible the toc frame only 2.if click chapter link means visible like chapter link.. am don't know about *. how to delete delete the Frame created by another button.

Comment on if click radio button not working separatly?
Download Code
Re: if click radio button not working separatly?
by hdb (Parson) on Apr 30, 2013 at 08:14 UTC

    virudinesh: ++ for your question this time. What you were looking for is the destroy function. I have added a few global variables for convenience. In both subs, I use the same variable for the new frame and destroy it first (if it was defined before). I hope this is close to what you wanted to achieve. I removed a bit of code just for clarity. Please always use strict; use warnings;

    use strict; use warnings; use Tk; my $mw = new MainWindow(-background=>'Gray'); $mw->geometry("1400x800"); $mw ->optionAdd('*background','Gray'); my @wb; my $file; my $flag; my $frame_name; my $frme_window; my $def_path1; $wb[0] = $mw->Radiobutton( -variable => \$file, -command => \&toclink, -text => 'TOC LINK', -font => "r18", -width => 17, -foreground => 'black', -value => 1)->pack(-side=> 'top',-anchor=>'w',)->place(-relx =>0. +0,-rely =>0.20); $wb[1] = $mw->Radiobutton( -variable => \$file, -command => \&chapterlink, -text => 'CHAPTER LINK', -font => "r18", -width => 17, -foreground => 'black', -value => 2)->pack(-side=> 'top',-anchor=>'w',)->place(-relx =>0.0 +15,-rely =>0.25); $wb[2] = $mw->Radiobutton( -variable => \$file, -command => sub {$flag =3;}, -text => 'FIGURE LINK', -font => "r18", -width => 17, -foreground => 'black', -value => 3)->pack( -side => 'top', -anchor => 'w',)->place(-relx =>0.007, -rely =>0. +30); MainLoop(); sub toclink() { $frme_window->destroy() if defined $frme_window; $frme_window = $mw -> Frame( -background => 'DarkGray', -relief => 'sunken')->pack(-ipadx => 330,-ipady =>0, - +side => "right", -fill => "y"); $frme_window->Label( -text =>"Do You Want Give Input Styles: ", -font => 'Verdana 10 bold', -foreground => 'dark red', -background => 'DarkGray', -height => 1,-width =>28) -> pack( )->place( -relx =>0 +.02, -rely =>0.08); $frme_window->Button( -foreground => 'dark red', -text => "yes", -font => 'Verdana 8 bold', -height => 1, -width => 10, -background => 'DarkGray', -command => \&enable) -> pack ( )->place(-relx =>0.43, + -rely =>0.08); $frme_window->Button( -foreground => 'dark red', -text => "No", -font => 'Verdana 8 bold', -height => 1, -width => 10, -background => 'DarkGray', -command => \&disable) -> pack ( )->place( -relx =>0.5 +7, -rely =>0.08); } sub chapterlink() { $frme_window->destroy() if defined $frme_window; $frme_window = $mw -> Frame( -background => 'DarkGray', -relief => 'sunken')->pack(-ipadx => 330,-ipady =>0, - +side => "right", -fill => "y"); my $butn =$frme_window->Label( -text =>'CHAPTER LINK ', -font => 'Verdana 15 bold', -foreground => 'dark red', -background => 'DarkGray', -height => 1, -width =>23) -> pack( )->place( -relx =>0.3, -rely =>0 +.1); my $labl = $frme_window->Label( -text =>"Chapter Files ", -font => 'Verdana 10 bold', -foreground => 'dark red', -background => 'DarkGray', -height => 1, -width =>15) -> pack( )->place(-relx =>0.01, -rely +=>0.30); my $path_text6 = $frme_window->Entry( -textvariable => \$def_path1, -font => 'Verdana 8 bold', -width => 35, -background =>'white')->pack(-expand => 1)->place(-rel +x => 0.20, -rely => 0.3); my $path_butn1 = $frme_window->Button( -foreground => 'dark red', -text => "Browse", -font => 'Verdana 8 bold', -height => 1,-width => 10, -command => \&browsecl) -> pack ( )->place( -relx = +>0.65, -rely =>0.3); my $path_buttn2 = $frme_window->Button( -foreground => 'dark red', -text => "Submit", -font => 'Verdana 8 bold', -height => 1, -width => 10, -command => \&submitcl) -> pack ( )->place(-relx =>0.8 +0, -rely =>0.3); }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1031345]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-08-29 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (289 votes), past polls