in reply to Balloon and menus options

You don't seem to assign anything to the hash entry $balloon_wg{pulldown} (or to the hash %balloon_wg at all) anywhere in the script...

Replies are listed 'Best First'.
Re^2: Balloon and menus options
by merrymonk (Hermit) on Dec 07, 2009 at 14:07 UTC
    Thanks to you both. Absolutely correct!
    Therefore I added the following.
    $wg{Status_Label} = $mw->Label(-borderwidth => 2, -relief => 'groove') ->pack(-side => 'bottom'); $balloon_wg{pulldown} = $mw->Balloon(-statusbar => $wg{Status_Label}); $balloon_wg{pulldown}->attach($wg{APullDown_Option}, -msg => [@mes_opt +ions]); # lines A #$balloon_wg{pulldown}->attach($wg{APullDown_Option}, -state => 'ballo +on', # -msg => ['A1', 'B2','C3', 'D4']); # line B #$balloon_wg{pulldown}->attach($wg{APullDown_Option}, -msg => [@mes_op +tions]);
    As you can see there are two options , two lines for A and one for B
    For both I got messages of the form
    Malformed UTF-8 character (unexpected continuation byte 0xb6, with no preceding start byte) in null operation at ….site/lib/Tk.pm line 406.
    How can I cure this?

      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)

        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.
      How can I cure this?

      it would help if you could come up with a small example that gives the error, and the exact platform you are on..... it now sounds like a different problem, probably unicode related..... and you probably should use strict completely, not just strict 'vars'


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku
        Below is code that shows the problem. It has two pull down menus.
        I have tried to use an array with messages for the first.
        I have given the messages in [] for the second.
        I have also just just 'strict'.
        In both case it fails to show the message I want to see.
        I am using Perl with Windows XP Professional operating system.
        Therefore any clues as to what is wrong would be excellent.
        use Tk; use Tk::Balloon; use strict ; my ($mw); my (%tooltip_mes, %tooltip_status_mes, %balloon_wg, %wg, @local_option +s, @mes_options, @sta_options, $option_resb, $option_res); $mw = MainWindow->new(-title => "Simple example"); $local_options[0] = 'Option 1'; $local_options[1] = 'Option 2'; $local_options[2] = 'Option 3'; $local_options[3] = 'Option 4'; $mes_options[0] = "tooltip 1\nOption A"; $mes_options[1] = "tooltip 2\nOption B"; $mes_options[2] = "tooltip 3\nOption C"; $mes_options[3] = "tooltip 4\nOption D"; $wg{APullDown_Option} = $mw->Optionmenu( -textvariable => \$option_res, -state => 'normal', -options => [@local_options])->pack; $wg{BPullDown_Option} = $mw->Optionmenu( -textvariable => \$option_resb, -state => 'normal', -options => [@local_options])->pack; $wg{Status_Label} = $mw->Label(-borderwidth => 2, -relief => 'groove') ->pack(-side => 'bottom'); $balloon_wg{pulldown} = $mw->Balloon(-statusbar => $wg{Status_Label}); $balloon_wg{pulldown}->attach($wg{APullDown_Option}, -msg => [@mes_opt +ions]); $balloon_wg{bpulldown} = $mw->Balloon(-statusbar => $wg{Status_Label}) +; $balloon_wg{bpulldown}->attach($wg{BPullDown_Option}, -state => 'ballo +on', -msg => ['A1', 'B2','C3', 'D4']); MainLoop;

        None of the hits I checked (the first 10) had anything to do with this specific Optionmenu issue.