Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl TK - deselect radiobutton ?

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
IL
HI,

With the following code the button comes up selected.
How do I get it deselected on startup ?
======================================================

my $but4 = $mw -> Radiobutton(-text=>"QUIT", -command =>\&KILL_DOWNLOAD)-> pack(qw/-side left/);
$but4->deselect();

thanks


Long live king Moshiach !
 
Hey,

Code:
Taken from: [URL unfurl="true"]http://www.geocities.com/binnyva/code/perl/perl_tk_tutorial/widgets3.html[/URL]
$widget -> deselect(); Deselects the checkbutton and sets the associated variable to its "off" value. $rdb_m -> deselect(); 
$widget -> select() Selects the checkbutton and sets the associated variable to its "on" value. $rdb_m -> select();

Chris
 
Thanks,

I have the following code,and all the 4 buttons come up selected:

my $but1 = $mw -> Radiobutton(-text=>" Install patches ",-value=>"$VOLUME",-command =>[\&actual,'patches'])-> pack(qw/-side left/); #Start button
my $but2 = $mw -> Radiobutton(-text=>" Install hotfixes ",-command =>[\&actual,'hotfixes'])-> pack(qw/-side left -padx 20/); #Stop button
my $but3 = $mw -> Radiobutton(-text=>" Install both ",-command =>[\&actual,'both'])-> pack(qw/-side left -padx 20/); #both button
my $but4 = $mw -> Radiobutton(-text=>"QUIT", -command =>\&KILL_DOWNLOAD)-> pack(qw/-side left/); #Quit button

#$but1->deselect();
$but2->deselect();
$but3->deselect();
$but4->deselect();


Any ideas why ?

Long live king Moshiach !
 
I have never been able to use TK although I want to.

Wondering why this line of code is:
#$but1->deselect();

You have commented it with #. So shouldn't it be
$but1->deselect();
?

Have you tried using a simpler bit of code just to check if that works... I.e. test

Code:
my $but1 = $mw -> Radiobutton(-text=>"Occupied",
	                     -variable=>\$occupied);
         $but1 -> deselect();

If that works (which I have pretty much copied and pasted from documentation) then it is possibly a problem with the other parts of code you have used.

Chris
 
Hi

I am giving you an example, with a frame, two radio buttons, and 2 cmd buttons, it will show you how to set a rb, "on/off"

Code:
#!/usr/bin/perl
use strict;
use Tk;
use Tk::LabFrame;


my $mw = MainWindow->new;
$mw->geometry("300x100+100+120");  
$mw->minsize(300,100);
$mw->maxsize(300,100);

my $code_font = $mw->fontCreate('code', -family => 'Arial',
						-size => 8,
						-weight => 'normal');    
						
my $code_font2 = $mw->fontCreate('code2', -family => 'Arial',
						-size => 9,
						-weight => 'bold');   


# Default value
my $version = "S11"; 

&create_framed_optionfield($mw);
MainLoop;

sub create_framed_optionfield {
	# The widget to set this frame in
	my $mother = shift;

	my $frame = $mother->LabFrame(
		-label => "BSC Version",
		-labelside => 'acrosstop',
		-width => 110,
		-height => 50,
		)->place(-x=>10,-y=>10); 
		
    my $frame2 = $mother->LabFrame(
		-label => "BSC Version",
		-labelside => 'acrosstop',
		-width => 110,
		-height => 50,
		)->place(-x=>10,-y=>120);

	# Put these values into the frame
	$frame->Radiobutton(
		-variable => \$version,
		-value => 'S11',
		-text => 'S11',
		)->place( -x => 10, -y => 0 );
	$frame->Radiobutton(
		-variable => \$version,
		-value => 'S105',
		-text => 'S105',
		)->place( -x => 10, -y => 20 ); 
		

    my $cb_1  = $mw->Button(-text    => "Checking",
                         -font    => 'code', 
                         -foreground       => 'blue',
                         -activebackground => 'green',
                        -width => 8,
                         -command => sub{&ToDo;}
                         )->place(-x=> 150, -y=>60);

   my $cb_2  = $mw->Button(-text    => "Cancel",
                         -state => 'normal',
                         -foreground       => 'blue',
                         -activebackground => 'green',
                         -font    => 'code',
                        -width => 8,
                        -command => sub {&killwin}
                         )->place(-x=> 220, -y=>60);    
	

 
}

 sub killwin{
 	 $mw->DESTROY if Tk::Exists($mw);
   exit;
 }
 
 sub ToDo{
 	print "Version: $version\n";
 }

dmazzini
GSM/UMTS System and Telecomm Consultant

 
Hi

Code below will select radio button "MULTIPLE":

Code:
$request_type = "MULTIPLE";

$mw->Radiobutton(
		-variable => \$request_type,  
		-foreground => 'blue',
		-value => 'SINGLE',
		-text => 'Single Option',		
		)->place( -x => 30, -y => 80 );

$mw->Radiobutton(
		-variable => \$request_type, 
		-foreground => 'blue',		
		-value => 'MULTIPLE',
		-text => 'Multiple Option',		
		)->place( -x => 30, -y => 100 );

dmazzini
GSM/UMTS System and Telecomm Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top