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.
Get Mastering Perl/Tk now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.