Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Tk::BrowseEntry with Tk::Balloon help

by redlemon (Hermit)
on Feb 21, 2005 at 14:13 UTC ( #433052=perlquestion: print w/ replies, xml ) Need Help??
redlemon has asked for the wisdom of the Perl Monks concerning the following question:

Valued confreres,

I'm looking for a way to provide extra information on entries in a Tk::BrowseEntry. I use -listcmd because in the application I'll be adding dynamically to the dropdown list. First try:

my @choices = qw/1 2 3/; my @help = qw/one two three/; my $top = MainWindow->new (); my $tag = $top->Balloon (-state => 'balloon'); my $entry = $top->BrowseEntry (%BE_args); $entry->configure ( -listcmd => sub { my $lb = $entry->Subwidget ('slistbox') ->Subwidget ('listbox' ); $entry->configure (-choices => \@choices); $tag->attach ($lb, -balloonmsg => \@help); } );

No luck. I thought that this could be caused by the listbox not being visible yet when listcmd() fires, so I tried:

my @choices = qw/1 2 3/; my @help = qw/one two three/; my $top = MainWindow->new (); my $tag = $top->Balloon (-state => 'balloon'); my $entry = $top->BrowseEntry (%BE_args); $entry->configure ( -listcmd => sub { $entry->configure (-choices => \@choices); } ); my $lb = $entry->Subwidget ('slistbox') ->Subwidget ('listbox' ); $lb->bind ( '<Visibility>' , sub { $tag->attach ( $lb , -balloonmsg => \@help ); } );

Again no luck. I've tried using the 'slistbox' subwidget itself, without success either. And I've verified that the Visibility callback actually triggers.

Is this even possible? If so, how?

Comment on Tk::BrowseEntry with Tk::Balloon help
Select or Download Code
Re: Tk::BrowseEntry with Tk::Balloon help
by zentara (Archbishop) on Feb 21, 2005 at 18:47 UTC
    I diddled with it for awhile before doing a groups.google search for "browseentry and balloon helpmsg"

    Jack D. figured it out, and you can google yourself for the full discussion, but the gist of it is that BrowseEntry does a GrabGlobal command which mucks things up. Try this:

    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Balloon; use Tk::BrowseEntry; # by Jack D. of comp.lang.perl.tk my $main = MainWindow->new; my $be = $main->BrowseEntry(-listcmd=>\&releaseGrab)->pack; $be->insert("end", "opt1", "opt2", "opt3"); my $sl = $be->Subwidget('slistbox'); my $l = $sl->Subwidget('scrolled'); my $b = $main->Balloon(); $b->attach($l, -balloonposition => 'mouse', -msg => ['first entry', 'second entry','third entry'] ); MainLoop(); sub releaseGrab{ $main->after(350,sub{$be->grabRelease}); # 350 ms is the init delay in the balloon # a smaller number will still likely work }

    I'm not really a human, but I play one on earth. flash japh

      Zentara, I bow to your wisdom and give you ++. That just solved it. Thanks.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (14)
As of 2014-12-18 15:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (56 votes), past polls