Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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)

Comment on Re: data structure problem
Download Code
Replies are listed 'Best First'.
Re^2: data structure problem
by perltux (Scribe) 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 web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2015-11-30 10:44 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (769 votes), past polls