Actually array elements are binded okay, problem is hidden in other place.

The point is - when you did -textvariable=>$arr[$i], Tk used those scalars as a references to Entry contents.

But after your assignment to entire @data something, you have new different scalars in there!

But if you'll do

@data[0..$#data] = ( 'a'..'x');
your code will work as you desired to!

Below is working code snippet for you to try:

use strict; use Tk; use Tk::Table; my $mw = tkinit; my @data = ( "init", "init", "init", "init" ); my $tableWidget = $mw->Table->form(-top=>'%0', -bottom=>['%100',-20], +-left=>'%0', -right=>'%100'); my $btn = $mw->Button( -command=>\&update, )->form(-top=>$tableWidget, -bottom=>'%100', -left=>'%0', -right=>'%10 +0'); my @headers = 'a'..'k'; my $e; for ( my $row=0; $row<2; $row++ ) { for( my $col=0; $col<$#headers+1; $col++) { my $e; if( $row == 0 ) { $e = $tableWidget->Button ( -relief => "groove", -justify => "left", -text => $headers[$col], -state => 'active', -width => length($headers[$col]) ); } else { $e = $tableWidget->Entry ( # -width => $lens[$col], -textvariable => \$data[$col] ); } $tableWidget->put( $row, $col, $e ); } } sub update { @data[0..$#data] = ( 'a'..'x'); } MainLoop;
Best wishes,
Baboon
PS.Weasel is stooped.

In reply to Re: Tk::Entry textvariable and array elements by Baboon
in thread Tk::Entry textvariable and array elements by rbc

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.