After some thinking, I came up with the following working solution.
use strict; use warnings; use Tk; my @w; my $mw = tkinit; $mw -> geometry("200x200"); our %MyValues=("1", "term1", "2", "term2", "3", "term3"); for my $DBcolumn (1..3) { $w[$DBcolumn]=$mw->Entry(-textvariable => \$MyValues{$DBco +lumn},-justify=>"left",-width => 25)->pack(-side => 'top', -anchor => + 'w'); } my $button1 = $mw->Button(-text => 'Update Values', -command => +\&LoadNewValues)->pack(); my $button2 = $mw->Button(-text => 'Print Out Content', -command + => \&PrintOutContent)->pack(); MainLoop(); sub PrintOutContent{ print "$MyValues{1} $MyValues{2} $MyValues{3}\n"; } sub LoadNewValues{ %MyValues=(); %MyValues=("1", "hallo", "2", "ok", "3", "fine"); for my $DBcolumn (1..3) { $w[$DBcolumn]->configure(-textvariable=>\$MyValues{$DBcolumn}); } }
In reply to Re: Updating Tk Entries with Hash
by Anonymous Monk
in thread Updating Tk Entries with Hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |