Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
more useful options
 
PerlMonks  

Tk::BrowseEntry with Tk::Balloon help

by redlemon (Hermit)
on Feb 21, 2005 at 09:13 UTC ( [id://433052]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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 (Cardinal) on Feb 21, 2005 at 13: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
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://433052]
Approved by Arunbear
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.