Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Tk -textvariable doesn't change when Entry widget changes

by JediWizard (Deacon)
on Sep 20, 2005 at 14:51 UTC ( #493474=note: print w/replies, xml ) Need Help??


in reply to Tk -textvariable doesn't change when Entry widget changes

I believe that you need to pass a reference to a (Update: Scalar) variable into the -textvariable parameter for an entry widget.

use Tk; require Tk::Entry; require Tk::Button; my $mw = MainWindow->new(); my($var1, $var2) = ('val1', 'val2'); my $entry1 = $mw->Entry(-textvariable=> \$var1)->pack(); my $entry2 = $mw->Entry(-textvariable => $var2)->pack(); my $but = $mw->Button(-text=>'print', -command=> sub{print "$var1, $va +r2\n"; } )->pack(); MainLoop; __END__ # Output upon pressing print after changeing both entry widget's: entry1, val2

Update: Please note that I intentioally left off the backslash on $val2 to demonstrate the different behavior when passing a simple value rather than a scalar reference.


They say that time changes things, but you actually have to change them yourself.

—Andy Warhol

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://493474]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-06-15 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (72 votes). Check out past polls.

    Notices?