in reply to tk form textvariables
IIRC Tk uses tied scalars for textvariables, so you need to update each scalar value in the hash separately. See the code below.
use Tk; my %current = (pilot => 'Harry'); my $mw = MainWindow->new; $mw->geometry('200x200'); my $ent = $mw->Entry( -textvariable => \$current{pilot}, )->pack; my $btn = $mw->Button( -text => 'New Pilot', -command => \&update, )->pack; MainLoop; sub update{ # This works $current{pilot} = 'Tom'; # This does not work %current = (pilot => 'Tom'); # So update the entire hash this way my %newstuff = (pilot => 'Tom', copilot =>'Dick', etc => 'Harry'); for (keys %newstuff){ $current{$_} = $newstuff{$_}; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: tk form textvariables
by liamlrb (Acolyte) on Mar 03, 2009 at 17:00 UTC | |
by liamlrb (Acolyte) on Mar 03, 2009 at 17:24 UTC | |
by hangon (Deacon) on Mar 03, 2009 at 18:42 UTC | |
|
Re^2: tk form textvariables
by liamlrb (Acolyte) on Mar 03, 2009 at 16:32 UTC |