I'm trying to write a script which involves a large number of pairs of Tk labels and entry boxes. I've written a sub to create each pair, pointing the textvariable to a hash, meaning to create a hash of entry box data keyed on a given key.
However, I do not seem to be able to get information out of the entry box hash - it seems that the data is not being assigned there in the first place. Can anyone see a way to solve this, or if what I am trying to do is not possible, is there an alternative solution? (would a global hash work?)
My code to create each label/entry box pair is below:
sub labelledEntry { my ($_objects, $objkey, $label, $width, $container) = @_; my %objects = %$_objects; $container -> Label( -text => $label ) -> pack( -side => 'left' ); $container -> Entry( -width => $width, -textvariable => \$objects{ +$objkey} ) -> pack( -side => 'right' ); return \%objects; }
and the code I'm using to get data out of the hash (the button code and subroutine to output it) is as follows:
$searchFrame -> Button( -text => 'search', -command => [ \&search, \$o +bjects{searchstr} ] )->pack( -side => 'left' ); sub search { my $text = shift; print STDERR $text; }
Any advice would be appreciated.
In reply to Tk Entry Widgets & Subs by Tanalis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |