in reply to why won't Tk textvariable take a reference to an array element?
before the:@status_label = ( "abc", "def" );
It will work.my $label1 = $frame_top->Label( -textvariable => \$status_label[0] ) ->grid( -row => 1, -column => 1 );
Otherwise the
my $label1 = $frame_top->Label( -textvariable => \$status_label[0] )
Update: (thanks runrig - see Re: why won't Tk textvariable take a reference to an array element?)
is referring to $status_label[0] which has not been defined yet.
Make that: "is referring to the original instance of $status_label[0] which is destroyed when you define a new array called @status_label by doing: @status_label = ( "abc", "def" );"
The magical thing is more the fact that the ones which use a reference to a scalar can be defined before the scalar has been populated with data.
The references are setting aside the promise that by the time MainLoop comes around to pack the components of the window together there will be some data sitting in the memory locations referred to by \$entry12, \$entry21 & \$entry22 for MainLoop to pick up and use as values.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: why won't Tk textvariable take a reference to an array element?
by peter.mao (Novice) on Jan 24, 2006 at 19:44 UTC |