Let's take Chmrr's example one step further... Here's a snippet of code that I use in one of my programs:
sub _usr_next { $window_hash->{main}{children}{label}->configure(-textvariable, $w +indow_hash->{main}{children}{text}); }
The configure method will set the parameter (in this case, -textvariable), to a new value. You can also use the get method to retrieve the value. So, let's say you need to update a label. You could make a button that calls the sample code as a callback. In total, it would look something like this. WARNING: UNTESTED!!!

#/usr/bin/perl -w use strict; use Tk; my $window_hash = {}; $window_hash->{main}->{main} = new MainWindow(); $window_hash->{main}->{children} = {}; $window_hash->{main}->{children}->{frame} = $window_hash->{main}{main} +->Frame()->grid(-column, 0, -row, 0, -sticky, 'news'); $window_hash->{main}->{globals}->{test1} = "hi"; $window_hash->{main}->{globals}->{test2} = "there"; $window_hash->{left_label} = $window_hash->{main}->{children}->{frame} +->Label(-textvariable, $window_hash->{main}->{globals}->{test1})->pac +k(-side, 'left'); $window_hash->{right_label} = $window_hash->{main}->{children}->{frame +}->Label(-textvariable, $window_hash->{main}->{globals}->{test2})->pa +ck(-side, 'right'); $window_hash->{test_button} = $window_hash->{main}->{children}->{frame +}->Button(-command, \&_usr_next())->pack(-side, 'bottom'); MainLoop; sub _usr_next { $window_hash->{left_label}->configure(-textvariable, $window_hash- +>{main}->{globals}->{test2}); $window_hash->{right_label}->configure(-textvariable, $window_hash +->{main}->{globals}->{test1}); }
The above method of using hash of hash of hashes method of Tk objects was suggested to me by NULE. It's actually a very creative method of making windows in Tk. The garbage collector apparently uses a linked list to store the parent and child windows, so you can put them anywhere and they will be properly garbage collected. I hope the example code is some help...

Theodore Charles III
Network Administrator
Los Angeles Senior High
4650 W. Olympic Blvd.
Los Angeles, CA 90019
323-937-3210 ext. 224
email->secon_kun@hotmail.com
perl -e "map{print++$_}split//,Mdbnr;"

In reply to Re: Setting value in Tk -textvariable by Necos
in thread Setting value in Tk -textvariable by Fideist11

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.