Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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?

Replies are listed 'Best First'.
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 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 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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (14)
As of 2016-07-01 16:23 GMT
Find Nodes?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?

    Results (9 votes). Check out past polls.