I'll just get right to the problem I am having. If you run the code below, I would expect that clincking on "var1 2" button would produce a "6" in the screen (Mainwindow) where -textvariable => \$var13 is displayed. This is not happening.

More curious, restart the progrem, click "CHG var1 3" button, See \$var13 correctly change to a "2" on the screen widget. Then click the "var1 2" See it not work (it should have changed t a "6"). Click "CHG var1 5", \$var15 is not changing.

Exit the program and re-start the program, See that both the "CHG var1 3" and "CHG var1 5" buttons work as I expected (expected being that the values are changed on the screen (manewindow widget))

Also, See that this all works as I would expect if you click the complementry "$var2" buttons. The only difference being one is "@var1", the other is "$var2"

Could someone tell me why clicking on the "var1 2" button is not producing a "6" in the screen?

use Tk; use strict; my $i; my @var1; my $var2; my $status; my $mw = MainWindow->new; #fill @var1 with zeros... for ($i = 0; $i <= 81; $i++) {$var1[$i] = 0;} #Do a similar thing with $var2 $var2 = 0; my $frame_01 = $mw->Frame(-background=>'grey')->pack(-side=>'top', -fi +ll => 'x'); my $frame_12 = $mw->Frame(-background=>'grey')->pack(-side=>'top', -fi +ll => 'x'); my $frame_13 = $mw->Frame(-background=>'grey')->pack(-side=>'top', -fi +ll => 'x'); my $frame_14 = $mw->Frame(-background=>'grey')->pack(-side=>'top', -fi +ll => 'x'); my $frame_15 = $mw->Frame(-background=>'grey')->pack(-side=>'top', -fi +ll => 'x'); $i = 1; $frame_01->Label(-text => "$i:", -width=>2, -relief => + 'flat') ->pack(-side =>'left'); $frame_01->Entry(-textvariable => \$var1[$i++], -width=>2, -relief => + 'sunken') ->pack(-side =>'left'); $frame_01->Entry(-textvariable => \$var1[$i++], -width=>2, -relief => + 'sunken') ->pack(-side =>'left'); $frame_01->Entry(-textvariable => \$var1[$i++], -width=>2, -relief => + 'sunken') ->pack(-side =>'left'); $frame_01->Label(-text => " ", -width=>1, -relief => + 'raised') ->pack(-side =>'left'); $frame_01->Entry(-textvariable => \$var1[$i++], -width=>2, -relief => + 'sunken') ->pack(-side =>'left'); $frame_01->Entry(-textvariable => \$var1[$i++], -width=>2, -relief => + 'sunken') ->pack(-side =>'left'); $frame_01->Entry(-textvariable => \$var1[$i++], -width=>2, -relief => + 'sunken') ->pack(-side =>'left'); $frame_12->Button(-text => "var1 1", -command => sub { change_var +1_1(@var1); }) ->pack(-side => 'left'); $frame_12->Button(-text => "var1 2", -command => sub { @var1 = ch +ange_var1_2(@var1); }) ->pack(-side => 'left'); $frame_12->Button(-text => "CHG var1 3", -command => sub { $var1[3] = + 2;}) ->pack(-side => 'left'); $frame_12->Button(-text => "CHG var1 5", -command => sub { $var1[5] = + 7;}) ->pack(-side => 'left'); $frame_13->Button(-text => "var2 1", -command => sub { change_var +2_1($var2); }) ->pack(-side => 'left'); $frame_13->Button(-text => "var2 2", -command => sub { $var2 = ch +ange_var2_2($var2); }) ->pack(-side => 'left'); $frame_13->Button(-text => "CHG var2", -command => sub { $var2 = 3; +}) ->pack(-side => 'left'); $frame_14->Label(-text => "var1[3] is:", -relief => 'flat') + ->pack(-side =>'left'); $frame_14->Label(-textvariable => \$var1[3], -relief => 'flat') + ->pack(-side =>'left'); $frame_14->Label(-text => ", var1[5] is:", -relief => 'flat') + ->pack(-side =>'left'); $frame_14->Label(-textvariable => \$var1[5], -relief => 'flat') + ->pack(-side =>'left'); $frame_14->Label(-text => ", var2 is:", -relief => 'flat') + ->pack(-side =>'left'); $frame_14->Label(-textvariable => \$var2, -relief => 'flat') + ->pack(-side =>'left'); $frame_15->Label(-text => "Status", -relief => 'flat') + ->pack(-side =>'left'); $frame_15->Label(-textvariable => \$status, -relief => 'flat') + ->pack(-side =>'left'); MainLoop(); sub change_var1_1 { @var1 = change_var1_2(@var1); $status = "change_var1_1 called $var1[3], $var1[5]"; } sub change_var2_1 { $var2 = change_var2_2($var2); $status = "change_var1_1 called $var2"; } sub change_var1_2 { my @lv_1 = @_; $lv_1[3] = 6; #$var1[3] = 6; # this works if you uncomment it $status = "change_var1_2 called $lv_1[3]"; return(@lv_1); } sub change_var2_2 { my $lv_2 = @_[0]; $lv_2 = 6; $status = "change_var2_2 called $lv_2"; return($lv_2); }

In reply to TK "textvariable" not updating with @var but ok with $var by mark4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.