Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by JediWizard (Deacon)
on Sep 20, 2005 at 14:51 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://493474]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found