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

Re: Updating variables in Tk programmes

by bobn (Chaplain)
on Sep 03, 2003 at 06:08 UTC ( [id://288574]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Updating variables in Tk programmes

I'm probably going to mess this up, but I think what's happening is:

You use \$map_fields[$cnt2] to store the location of (pointer to) the space occupied by $map_fields[$cnt2], but I think that the dereferencing of the array is happening first, so you store a reference to a string which is the value stored at $map_fields[$cnt2].

I think the solution is to initially store references to scalars in @map_fields, then always manipulate them as references, as in:
use Tk; $mw = new MainWindow(-title=>'mapp'); $pg = $mw->Frame; @map_fields = \(qw( A B C D E )); $cnt2 = 0; @file_fieldnames = qw( SHOW COLUMNS FROM lead SKIP ); foreach my $field ( @file_fieldnames ) { $pg->Label(-relief => 'sunken', -width => 15, -text => $field)->pac +k(); my $brb = $pg->BrowseEntry(-variable => ($map_fields[$cnt2]) ); $brb->insert('end', @$dbfields); $cnt2++; $brb->pack(); } my $btn =$pg->Button(-text=>'doit', -command => sub { doit() } ); $btn->pack; $pg->pack(); MainLoop; sub doit { $ifg->{parameter} = '1,2,3,4,5'; my @a = ( split ( ",", $ifg->{parameter} ) ); for ( @map_fields ) { $$_ = shift @a } ; }
This code seems to do what you want, though I didn't learn the grid placment manager or make a DB to truly try it out.

--Bob Niederman, http://bob-n.com

All code given here is UNTESTED unless otherwise stated.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://288574]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.