Home > Archive > PerlTk > February 2008 > Checkbutton
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| What is wrong with this:
$exCB = $MW -> Checkbutton(-text=>"exclusion",
-variable=>$eX,
-command=>sub{print "\n$eX\n";},
-onvalue=>"on",-offvalue=>"off");
However, the value of $eX does not change regardless of the button's
state (ie. command just prints "on" when you check the box, and "on" when
you uncheck it).
| |
| Paul Gaborit 2008-02-29, 7:09 pm |
|
À (at) Fri, 29 Feb 2008 10:08:45 -0600,
MK <halfcountplus@intergate.com> écrivait (wrote):
> What is wrong with this:
>
> $exCB = $MW -> Checkbutton(-text=>"exclusion",
> -variable=>$eX,
> -command=>sub{print "\n$eX\n";},
> -onvalue=>"on",-offvalue=>"off");
>
> However, the value of $eX does not change regardless of the button's
> state (ie. command just prints "on" when you check the box, and "on" when
> you uncheck it).
Try this "variant" :
$exCB = $MW->Checkbutton(-text => "exclusion",
-variable => \$eX,
-command => sub{print "\n$eX\n"},
-onvalue => "on",
-offvalue => "off");
and read the documentation (perldoc Tk::Checkbutton) :
[...]
Switch: -variable
Specifies *reference* to a variable...
[...]
--
Paul Gaborit - <http://perso.enstimac.fr/~gaborit/>
Perl en français - <http://perl.enstimac.fr/>
| |
| Marc Dashevsky 2008-02-29, 7:09 pm |
| In article < o9WdnQaoVraQs1XanZ2dnUVZ_j2dnZ2d@pghconn
ect.com>, halfcountplus@intergate.com
says...
> What is wrong with this:
>
> $exCB = $MW -> Checkbutton(-text=>"exclusion",
> -variable=>$eX,
> -command=>sub{print "\n$eX\n";},
> -onvalue=>"on",-offvalue=>"off");
>
> However, the value of $eX does not change regardless of the button's
> state (ie. command just prints "on" when you check the box, and "on" when
> you uncheck it).
Unless $eX is a reference to a scalar, you want:
-variable => \$eX,
--
Go to http://MarcDashevsky.com to send me e-mail.
| |
|
| On Fri, 29 Feb 2008 11:26:41 -0500, Marc Dashevsky wrote:
> Unless $eX is a reference to a scalar, you want:
>
> -variable => \$eX,
Correct you both are, i will watch for this word "reference" in the
future :)
|
|
|
|
|