I want to have a balloon (tooltip) on an optionmenu that is different for each Item on the drop down menu.I found an example which allegedly did this. However, it gave an error shown below.
The Perl below is this example which as it is now gives the same tooltip and message in a label for each menu option.The code that is supposed to give the variable message is hashed out.To see the error simply remove the #on the first -balloonmsg line and add a # to the second -balloonmsg line.
Can any wise Monk explain how to get a different message for each option on the pull-down menu?
#!/usr/local/bin/perl
use strict;
use warnings;
use Tk;
use Tk::Balloon;
my ($att_res);
my $mw = MainWindow->new();
$mw->title('Simple example');
my $status = $mw->Label(
-width => 20,
-relief => 'groove',
)->pack();
my $balloon = $mw->Balloon(-statusbar => $status, -initwait => 1);
my $menu = $mw->Optionmenu(
-textvariable => \my $res,
-options => [qw(A B C D)],
)->pack();
$att_res = 1234;
$att_res = $balloon->attach(
$menu, # pass the Tk::Menu instance
# the next line gave many errors of the form
#Malformed UTF-8 character (unexpected non-continuation byte 0xe5, imm
+ediately after start byte 0xf0)
# in subroutine entry at ......./lib/Tk.pm line 469.
# -balloonmsg => [qw(a b c d)],
-balloonmsg => 'foo',
-statusmsg => 'foo',
# this works, but you get the same msg for all menu entries, of co
+urse
);
print "att_res <$att_res\n";
MainLoop;
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.