On the website http://search.cpan.org/~srezic/Tk-804.028/pod/Balloon.pod
I found the following to attach balloons (tooltips) to individual options on a menu.
# Balloon attached to entries in a menu widget:
$b->attach($menu, -state => 'status',
-msg => 'first menu entry', </br> 'second menu entry', </br> ... </br> ,
);
I tried to use this as shown in the Perl below.
use Tk; use Tk::Balloon; use strict "vars"; my ($mw); my (%tooltip_mes, %tooltip_status_mes, %balloon_wg, %wg, @local_option +s, @mes_options, @sta_options, $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; # line that fails $balloon_wg{pulldown}->attach($wg{APullDown_Option}, -msg => [@mes_opt +ions]); MainLoop;
Sadly this fails with the message
Can't call method "attach" on an undefined value at line nn.
This is the line where I try to attach the balloon to the pull down menu. Without this line the pull down menu can be seen.
Does anyone know how to solve this?
Also, can messages to the status area be associated with each option of the pull down menu?

In reply to Balloon and menus options by merrymonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.