Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Tk BrowseEntry -listcmd problem

by jdtoronto (Prior)
on Aug 27, 2003 at 16:05 UTC ( [id://287078]=perlquestion: print w/replies, xml ) Need Help??

jdtoronto has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed monks,

I have a Perl/Tk application (which many here have helped with!) where I face an interesting dilemna.

$pgl->Label(-text => 'Project', -justify => 'right', -width => '20 +') ->grid($pr_list = $pgl->BrowseEntry(-variable => \$state-> +{prSrcName}, -browsecmd => \&doGetProject, -listcmd => [ \&doLoadPr, +$dbh, $pr_list ], -width => '20'), -sticky => 'w', -pady => '20');
In this code I wish to 'load' the list by calling a sub when the 'arrow' button is clicked. Naturally I would like to pass the variables in to the sub. But before the sub can know where to 'insert' the data it must have the handle for the widget! Now this is a case of the dog chasing its tail. I can't use the handle in the call to the sub till it has a value.

So, is it possible to pass the widget handle to a sub, from the the widget?

I know I can do it by making the widget handle a global, but hey I just don't wanna go down that road if I can avoid it.

jdtoronto

Replies are listed 'Best First'.
Re: Tk BrowseEntry -listcmd problem
by fletcher_the_dog (Friar) on Aug 27, 2003 at 17:06 UTC
    If I understand what you are trying to do, You could probably just hold off on setting your commands and use 'configure', like this:
    $pgl->Label( -text => 'Project', -justify => 'right', -width => '20') ->grid( $pr_list = $pgl->BrowseEntry( -variable => \$state->{prSrcName}, -width => '20'), -sticky => 'w', -pady => '20'); $pr_list->configure( -browsecmd => \&doGetProject, -listcmd => [ \&doLoadPr, $dbh, $pr_list ] );
      Thanks fletcher_the_dog - thats the way to solve it.

      I find the Perl/Tk documentation and "Mastering Perl/Tk" both ponderous when it comes to these sorts of questions.

      jdtoronto

        I've added a few links to Perl/Tk resources on my home node, you may find some of them useful when the docs and MPTK aren't clear enough.

        converter

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://287078]
Approved by ybiC
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-03-28 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found