Tk::Balloon in subroutines 
Author Message
 Tk::Balloon in subroutines

Hi,

I use Tk::Balloon (from Tk 800.022) this way:

#v+
my $b = $top->Balloon;
$b->attach($widget_in_MainWindow,
  -balloonmsg => 'text');                   # this works fine
...
sub conf
{
  my $conf = $main->Dialog;
  my $widget = $conf->Button(...);
  ...
  $b->attach($widget,
    -balloonmsg => 'text');                 # doesn't work!

Quote:
}

#v-

If I attach a balloon to a widget placed within the MainWindow widget,
everything works fine. But when I create a dialog or something in a
subroutine and want to attach a balloon message to any widget there,
the balloon doesn't appear, although I get no error message or warning
(even with the 'perl -w' switch). What am I doing wrong?

Johannes



Mon, 23 Jun 2003 18:55:46 GMT  
 Tk::Balloon in subroutines

Quote:

> I use Tk::Balloon (from Tk 800.022) this way:

> #v+
> my $b = $top->Balloon;
> $b->attach($widget_in_MainWindow,
>   -balloonmsg => 'text');                   # this works fine
> ...
> sub conf
> {
>   my $conf = $main->Dialog;
>   my $widget = $conf->Button(...);
>   ...
>   $b->attach($widget,
>     -balloonmsg => 'text');                 # doesn't work!
> }
> #v-

> If I attach a balloon to a widget placed within the MainWindow widget,
> everything works fine. But when I create a dialog or something in a
> subroutine and want to attach a balloon message to any widget there,
> the balloon doesn't appear, although I get no error message or warning
> (even with the 'perl -w' switch). What am I doing wrong?

I'm not certain, but I know that I would have written:

        use vars qw/$b/;
        $b = $top->Balloon;

rather than used $b as a "my" variable.

--
Marc Dashevsky  (remove "_" from address to reply by e-mail)



Mon, 23 Jun 2003 20:55:43 GMT  
 Tk::Balloon in subroutines

Quote:


> > my $b = $top->Balloon;
> > $b->attach($widget_in_MainWindow,
> >   -balloonmsg => 'text');                   # this works fine
> > ...
> > sub conf
> > {
> >   my $conf = $main->Dialog;
> >   my $widget = $conf->Button(...);
> >   ...
> >   $b->attach($widget,
> >     -balloonmsg => 'text');                 # doesn't work!
> > }
> I'm not certain, but I know that I would have written:

>    use vars qw/$b/;
>    $b = $top->Balloon;

> rather than used $b as a "my" variable.

Unfortunately, it still doesn't work. :-(
Maybe the dialog box is the reason? Doesn't Tk::Balloon work with this
widget?

Johannes



Fri, 27 Jun 2003 05:58:24 GMT  
 Tk::Balloon in subroutines

Quote:


> > > my $b = $top->Balloon;
> > > $b->attach($widget_in_MainWindow,
> > >   -balloonmsg => 'text');                   # this works fine
> > > ...
> > > sub conf
> > > {
> > >   my $conf = $main->Dialog;
> > >   my $widget = $conf->Button(...);
> > >   ...
> > >   $b->attach($widget,
> > >     -balloonmsg => 'text');                 # doesn't work!
> > > }
> > I'm not certain, but I know that I would have written:

> >       use vars qw/$b/;
> >       $b = $top->Balloon;

> > rather than used $b as a "my" variable.

> Unfortunately, it still doesn't work. :-(
> Maybe the dialog box is the reason? Doesn't Tk::Balloon work
> with this widget?

Apparently not.  Fortunately, given what I saw in your other message
today, you don't want Dialog (or DialogBox), you want to use Toplevel.

This worked fro me:

        use strict;
        use Tk;
        use Tk::Dialog;
        use Tk::Balloon;
        use vars qw/$Top $Balloon/;

        $Top = tkinit;
        my $button = $Top->Button(-command => \&sub)->pack;
        $Balloon = $Top->Balloon;
        $Balloon->attach($button, -balloonmsg => 'Push this');
        MainLoop;

        sub sub
        {
            my $dialog = $Top->Toplevel;
            my $widget = $dialog->Label(-text => 'Label')->pack;
            $Balloon->attach($widget, -balloonmsg => 'text');
        }

--
Marc Dashevsky  (remove "_" from address to reply by e-mail)



Fri, 27 Jun 2003 06:33:10 GMT  
 Tk::Balloon in subroutines

Quote:



> > > my $b = $top->Balloon;
> > > $b->attach($widget_in_MainWindow,
> > >   -balloonmsg => 'text');                   # this works fine
> > > ...
> > > sub conf
> > > {
> > >   my $conf = $main->Dialog;
> > >   my $widget = $conf->Button(...);
> > >   ...
> > >   $b->attach($widget,
> > >     -balloonmsg => 'text');                 # doesn't work!
> > > }
> > I'm not certain, but I know that I would have written:

> >       use vars qw/$b/;
> >       $b = $top->Balloon;

> > rather than used $b as a "my" variable.

> Unfortunately, it still doesn't work. :-(
> Maybe the dialog box is the reason? Doesn't Tk::Balloon work with this
> widget?

DialogBox uses a grab and balloons don't show if there is a grab...
What you can do: create a new inherited Balloon class and override all
methods which tests for an active grab and remove those tests.

Eg. from

    return if ($s || $ewin->grabCurrent());

to

    return if $s;

Regards,
        Slaven

--
use Tk;$c=tkinit->Canvas(-he,20)->grid;$x=5;map{s!\n!!g;map{create$c 'line'=>
map{$a=-43+ord;($x+($a>>3)*2=>5+($a&7)*2)}split''}split"!";$x+=12}split/_/=>'K
PI1_+09IPK_K;-OA1_+K!;A__1;Q!7G_1+QK_3CLPI90,_+K!;A_+1!KQ!.N_K+1Q!.F_1+KN.Q__1+
KN._K+1Q!.F_1+KN.Q_+1Q__+1!KQ!.N_1;Q!7G_K3,09Q_+1!K.Q_K+1Q!.F_1+KN.Q_';MainLoop



Sat, 28 Jun 2003 23:22:37 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Tk::Text, tags and Tk::Balloon

2. Errormessage: Tk::Balloon and Tk::Listbox

3. Tk::Balloon and warning message?

4. [Fwd: Problem with Tk::Balloon.pm on Tk800.010]

5. Problem with Tk::Balloon.pm on Tk800.011 ?

6. Problem with Tk::Balloon.pm on Tk800.011 ?

7. Problem with Tk::Balloon.pm on Tk800.010

8. Tk::Balloon attached to DialogBox widgets?

9. Bug with Tk::Balloon ??

10. Tk::Balloon text formating

11. Tk::Balloon Upgrade?

12. PATCH: Tk::Balloon (Canvas Leak Reminder)

 

 
Powered by phpBB® Forum Software