start page | rating of books | rating of authors | reviews | copyrights

Book HomeMastering Perl/TkSearch this book

4.23. Turning a Checkbutton/Radiobutton On and Off

You can force the Checkbutton or Radiobutton from on to off or vice versa using the deselect and select methods.

The deselect method will always set the indicator to the off state and the variable assigned by -variable to the value in -offvalue. On a Radiobutton, using deselect causes the Radiobutton to be unselected. It sets the $variable to an empty string. If you use this method, make sure you account for it in any code that evaluates the value of $variable.

$cb->deselect( );
$rb->deselect( );

The opposite of deselect, select, sets the indicator to the on state and the variable assigned by -variable to the -onvalue or -value, if using a Radiobutton.

$cb->select( );
$rb->select( );

Both methods are ignored if -state is 'disabled'.

You can also toggle the indicator from on to off or vice versa using the toggle method:

$cb->toggle( );
$rb->toggle( );

Calling toggle does not cause the subroutine associated with the -command value to be called.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.