Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: data structure problem

by graff (Chancellor)
on Nov 08, 2012 at 04:12 UTC ( #1002800=note: print w/replies, xml ) Need Help??

in reply to data structure problem

Your hash of arrays idea seems like a perfectly sensible approach. Whether the structure is hard-coded or is somehow input-dependent, you can easily manage the BrowseEntry widgets:
... # populate %hash as per the OP # create $first_BrowseEntry, then: $first_BrowseEntry->insert( "end", $_ ) for ( sort keys %hash ); ... sub first_browse_callback { $second_BrowseEntry->delete( 0, "end" ); my $chosen = $first_BrowseEntry->get; $second_BrowseEntry->insert( "end", $_ ) for ( sort @{$hash{$chose +n}} ); }
There'll be more code than that, of course, but not a lot more. When you create the first_BrowseEntry widget, you'll include the "first_browse_callback" function as the "-browsecmd" option value.

(updated to use consistent naming on the widget variable)

Replies are listed 'Best First'.
Re^2: data structure problem
by perltux (Monk) on Nov 08, 2012 at 04:52 UTC
    Many thanks for your reply!

    It cleared my doubt whether I was on the right track with regards to the data structure and your 'first_browse_callback' code snippet helped me greatly with implementing the callback to modify the second widget based on the user selection of the first widget.
    My code is working fine now.

    You saved me from hours of frustrating experimentation! :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002800]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2018-03-25 00:11 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (299 votes). Check out past polls.