Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2022-01-17 17:21 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (51 votes). Check out past polls.