O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required