Mikster has asked for the wisdom of the Perl Monks concerning the following question:
When the line#!/usr/bin/perl -w use strict; use Tk; my @SLIDERVALUES = (0, 0, 0, 0); my @slider; my $i; sub show_array { print "\@SLIDERVALUES = ($SLIDERVALUES[0], $SLIDERVALUES[1], $SLIDER +VALUES[2], $SLIDERVALUES[3])\n"; } # window setup my $mw = MainWindow->new; foreach my $i (0 .. 3) { $slider[$i] = $mw->Scale (-from => 30, -to => 0, -orient => 'vertical', -variable => \$SLIDERVALUES[$i], )->pack ( -side => 'left', ); } show_array(); # This breaks things! @SLIDERVALUES = (5, 10, 15, 20); show_array(); $SLIDERVALUES[0] = 7; $SLIDERVALUES[1] = 14; $SLIDERVALUES[2] = 21; $SLIDERVALUES[3] = 28; show_array(); MainLoop;
@SLIDERVALUES = (5, 10, 15, 20);
is commented out, the command line output is
and the sliders take up position at 7, 14, 21, and 28, as expected.@SLIDERVALUES = (0, 0, 0, 0) @SLIDERVALUES = (0, 0, 0, 0) @SLIDERVALUES = (7, 14, 21, 28)
If, however, that line is not commented out, we get
at the command line, and the sliders all stay at 0.@SLIDERVALUES = (0, 0, 0, 0) @SLIDERVALUES = (5, 10, 15, 20) @SLIDERVALUES = (7, 14, 21, 28)
I'd like to understand how the -variable option is being ignored, and I'd also like tips on how I could have further diagnosed this problem.
Many thanks...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl/Tk and the "-variable => \$var" option
by graff (Chancellor) on Jun 19, 2005 at 18:20 UTC | |
|
Re: Perl/Tk and the "-variable => \$var" option
by davidrw (Prior) on Jun 19, 2005 at 18:18 UTC | |
|
Re: Perl/Tk and the "-variable => \$var" option
by zentara (Cardinal) on Jun 20, 2005 at 12:02 UTC | |
|
Re: Perl/Tk and the "-variable => \$var" option
by zentara (Cardinal) on Jun 20, 2005 at 12:28 UTC |