Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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 the sunlight beams...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2018-07-15 23:28 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (328 votes). Check out past polls.