in reply to Re^4: Balloon and menus options
in thread Balloon and menus options

Many thanks to everyone who has looked at this. It would seems that
I will not be able to use the advertised method of associating tooltips with individual options on a pull down menu.
Perhaps the other things, such as working with items in a list box or canvas, will not work either.
Unless someone knows different!

Replies are listed 'Best First'.
Re^6: Balloon and menus options
by zentara (Cardinal) on Dec 08, 2009 at 13:11 UTC
    It would seems that I will not be able to use the advertised method of associating tooltips with individual options on a pull down menu

    .... switch to Gtk2 .... ;-) .... not that I have corresponding Gtk2 code for that, but at least the development is very active.....and bugs get fixed quick..... poor old Tk still does simple things well, but it's getting old and neglected


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
Re^6: Balloon and menus options
by lamprecht (Friar) on Dec 08, 2009 at 22:46 UTC
    Hi,

    A Tk::Optionmenu isa Tk::Menubutton. You want to attach a balloon to a Tk::Menu here. You can access the menu associated with a Optionmenu-button using the menu() method:

    #!/usr/local/bin/perl use strict; use warnings; use Tk; use Tk::Balloon; my $mw = MainWindow->new(); $mw->title('Simple example'); my $status = $mw->Label( -width => 20, -relief => 'groove', )->pack(); my $balloon = $mw->Balloon(-statusbar => $status); my $menu = $mw->Optionmenu( -textvariable => \my $res, -options => [qw(A B C D)], )->pack(); $balloon->attach( $menu->menu, # pass the Tk::Menu instance -msg => [qw(a b c d)], #-msg => 'foo', # this works, but you get the same msg for all menu entries, of co +urse ); MainLoop;

    works as expected on Linux. Windows is special in that events over Menu windows are not passed to Tk so Ballon will not work here. <Motion> bindings will not trigger here either...

    And - yes: Balloon works with Listbox as well as with Canvas.


    Cheers, Christoph
      ...works as expected on Linux.

      Just tried it (because it looked like a good idea), but it doesn't seem to work for me, i.e. with $menu->menu I no longer get any tooltips at all, not even random junk ones. — Just for the record.  (Linux, Perl 5.8.8, Tk 804.027)

        I tested with Tk 804.028_500 using compiz and metacity window managers and it works in both cases.


        Cheers, Christoph