sub LoadNewValues{ %MyValues=(); %MyValues=("1", "hallo", "2", "ok", "3", "fine"); }

The basic problem with this  LoadNewValues() function from the OPed code is that it assigns a new set of referents to the global  %MyValues hash, but it does not change the referents originally assigned as  -textvariable references in the  $mw->Entry(-textvariable => ...) statements. (I hope I've made myself clear on this point; references are tricky.)

Using something like your original approach, this works as I expect you expected it would:

c:\@Work\Perl\monks>perl -le "use warnings; use strict; ;; use Tk; ;; my $mw = tkinit; $mw->geometry('200x200'); ;; our %MyValues = qw(1 term1 2 term2 3 term3); ;; for my $DBcolumn (1..3) { $mw->Entry( -textvariable => \$MyValues{$DBcolumn}, -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 qq{$MyValues{1} $MyValues{2} $MyValues{3}}; } ;; my $inc_them; sub LoadNewValues { if ($inc_them++) { $MyValues{$_}++ for qw(1 2 3); } else { @MyValues{ qw(1 2 3) } = qw(hallo ok fine); } } " term1 term2 term3 hallo ok fine hallp ol finf hallq om fing

Update: The code using  configure() that you posted here works fine, but does not address the basic conceptual problem with handling references that lurks in the OPed code.


Give a man a fish:  <%-{-{-{-<


In reply to Re: Updating Tk Entries with Hash by AnomalousMonk
in thread Updating Tk Entries with Hash by Anonymous Monk

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.