Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Heya! Im having real problems with a checkbutton. I cant get it to set to on when the page loads without it looking like a button!

I also cannot figure out how to make it respoind to a variable, i.e.

$variable = "1";

So i would expect the $variable when implemented somewhere in a checkbutton to turn it on, however i have gone over all the commands and i just cannot find the correct way to do this!

Also, I wonder if anyone could tell me if im correct in assuming the variable the check button is (i.e. my $chkbutt = $window->checkbutton()) is the valkue of the button when it comes to using it. I.e. if the ubtton is selected, $chkbutt = "1"!

Thanks!

Replies are listed 'Best First'.
Re: TK Checkbuttons!
by zentara (Cardinal) on Mar 28, 2004 at 14:48 UTC
    #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new( -bg => 'black' ); $mw->geometry('150x30+10+15'); #select default case matching my $case = 1; #or 0 for nocase default my $casesw = $mw->Checkbutton( -selectcolor=>'green', -text=>'Match Case', -offvalue=> 0, -onvalue=> 1, -variable=>\$case, ); $casesw->pack(-side=>'right', -fill => 'x',-expand=>1 ); MainLoop;

    I'm not really a human, but I play one on earth. flash japh
Re: TK Checkbuttons!
by rinceWind (Monsignor) on Mar 28, 2004 at 13:03 UTC
    Please post some code.

    From what you have said, you need to specify the options: -variable, -onvalue and -offvalue. If you initially set $variable to the on value before calling MainLoop, the button will appear in an on state.

    Note that -variable expects a reference to the variable you are passing.

    See the documentation.

    --
    I'm Not Just Another Perl Hacker