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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access