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

I can replicate the problem (but mind you, I'm no Tk-wiz either).  I.e. with the following simple test script

#!/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, -msg => [qw(a b c d)], #-msg => 'foo', # this works, but you get the same msg for all menu entries, of co +urse ); MainLoop;

it seems that random strings from memory are being displayed as tooltip texts, which would also explain the "Malformed UTF-8 character" messages (because a random sequence of bytes is typically not well-formed UTF-8).

Apparently, the -msg => [...] doesn't work as advertised  (a simple scalar "works", but that of course doesn't make much sense for a menu...).

(Perl 5.8.4, $Tk::VERSION: 804.027 — I don't have anything more recent on this box)

Replies are listed 'Best First'.
Re^4: Balloon and menus options
by Anonymous Monk on Dec 07, 2009 at 17:05 UTC
    I can confirm with the latest Tk: 804.028501
    Malformed UTF-8 character (unexpected continuation byte 0x8c, with no +preceding start byte) in subroutine entry at C:/perl/site/5.10.1/lib/ +MSWin32-x86-multi-thread/Tk.pm line 423. UCS-2LE:partial character is not allowed when CHECK = 0x264 at C:/perl +/site/5.10.1/lib/MSWin32-x86-multi-thread/Tk.pm line 423. Unable to free colormap, palette is still selected. This application has requested the Runtime to terminate it in an unusu +al way. Please contact the application's support team for more information.
      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!
        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
        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