rbc has asked for the wisdom of the Perl Monks concerning the following question:
... and I would update the displayed textvariables by calling the sub ...#global vars @data = ( "init", "init", "init", "init" ); 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 ); } }
... the problem I am having is that although @data changes the displayed textvariables in my Entry widgets are not changing. So what I had to do was write this ugly code.sub update { ... @data = ( / ... big long regex ... /g); ... }
... this works but I bet there is a better way. Please bestow your wisdom. Thank you... # global variables my $col_0; my $col_1; my $col_2; my $col_3; ... 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 { if ( $col == 0 ) { $e = $tableWidget->Entry ( -width => $lens[$col], -textvariable => \$col_0); } elsif ( $col == 1 ) { $e = $tableWidget->Entry ( -width => $lens[$col], -textvariable => \$col_1); } elsif ( $col == 2 ) { $e = $tableWidget->Entry ( -width => $lens[$col], -textvariable => \$col_2); } elsif ( $col == 3 ) { $e = $tableWidget->Entry ( -width => $lens[$col], -textvariable => \$col_3); } $tableWidget->put( $row, $col, $e ); } } } ... sub update { ... @data = ( / ... big long regex ... /g); ... $col_0 = data[0]; $col_1 = data[1]; $col_2 = data[2]; $col_3 = data[3]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk::Entry textvariable and array elements
by Baboon (Acolyte) on Jun 12, 2002 at 19:24 UTC |