View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Michael Krause > Tk-MK > Tk::Checkbox



Annotate this POD


New  1
Open  0
View/Report Bugs
Module Version: 2.7   Source  


Tk::Checkbox - Yet Another Checkbutton widget (with a sizable marker)


    use Tk;
    use Tk::Checkbox;

    my $var = 'Up';
    my $mw = MainWindow->new();

    my $cb1 = $mw->Checkbox (
        -variable => \$var,
        -command  => \&test_cb,
        -onvalue  => 'Up',
        -offvalue => 'Down',
        #-noinitialcallback => '1',
                #-size => '8',
    sub test_cb
        print "test_cb called with [@_], \$var = >$var<\n";


Another check button style widget that uses a check mark in a fixed box. Useful as a boolean field. It's based on Damion K. Wilson's version from Tk-DKW-0.03, suitable for perl Tk800.x (developed with Tk800.024).

You can tie a scalar-value to the Checkbox widget, enable/disable it, assign a callback, that is invoked each time the Checkbox is changed, as well as set ON- and OFF-values and configure any of the options understood by Tk::Frame(s) like -relief, -bg, ... .



'set($newvalue)' allows to set/reset the the widget methodically, $newvalue must be either 'onvalue' or 'offvalue'.

You should prefer interacting with the widget via a variable.



'-variable' allows to specify a reference to a scalar-value. Each time the widget changes by user interaction, the variable is changed too. Every variable change is immediately mapped in the widget too.


'-command' can be used to supply a callback for processing after each change of the Checkbox value.


'-onvalue' can be used to supply a value that is used/returned, if the checkmark is 'checked'. default is '1'.


'-offvalue' is the opposite of 'onvalue', it isused/returned, if the checkmark is 'unchecked'. default is '0'.


'-noinitialcallback' can be used to suppress the invocation of an (assigned) callback, immediate after a (new) variable has been configured with -variable.


'-size' can be used to specify the widget- (and checker) size (default 15 pt)


Michael Krause, KrauseM_AT_gmx_DOT_net

This code may be distributed under the same conditions as Perl.

V2.8 (C) September 2011

syntax highlighting: