Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Tk::Balloon and unclunky menus.

by aplonis (Pilgrim)
on Feb 01, 2012 at 00:27 UTC ( #951101=perlquestion: print w/ replies, xml ) Need Help??
aplonis has asked for the wisdom of the Perl Monks concerning the following question:

Anyone have an example of attaching a Tk balloon to a Tk menu list when the list is configured per the "unclunky" (slick,sophisticated, new-fashioned) way of Mastering Perl/Tk (1st Ed) on page 261 like so...?

map { $menubar->cascade( -label => '~' . $_->[0], -menuitems => $_->[1 +]) } [ 'Choices', char_string ]; sub char_string { [ ['command', 'foo', -command => sub { $char_string = "this"} ], ['command', 'bar', -command => sub { $char_string = "that"} ], ] }

That works fine without balloons. But for adding balloons to menus, the CPAN docs show an example similar to...

$b->attach( $menu, -state => 'balloon', -msg => [ 'Do this...', 'Do that...', ], );

...which requires a scalar "$menu". With the map construction I no not how to get such a scalar. I could get scalars for "$menu" as I do the "clunky" way from page 259. But I hate to go back to clunkyness.

Anybody got an example? My Perl is very rusty from not using it much these past 5 years. So please translate answers into noobish if possible. Thanks.

Comment on Tk::Balloon and unclunky menus.
Select or Download Code
Re: Tk::Balloon and unclunky menus.
by Anonymous Monk on Feb 01, 2012 at 03:15 UTC
    map { my $junk = $men.... $globalBaloonWidget->attach( $junk, -balloonmsg => $_->[-1] ); ...

      That seems not to quite work. After several tries I reduced my usage to a simpler experimental case, thus...

      my $whatever; use subs qw/bar/; map { my $menu = $menubar->cascade( -label => '~' . $_->[0], -menuitems => $_->[1]); $balloon->attach( $menu, -state => 'balloon', -msg => 'foo'); } [ 'Foo', bar ]; sub bar { [ ['command', 'This', -command => sub { $whatever = 'Does this.'}], ['command', 'That', -command => sub { $whatever = 'Does that'}], ] }

      But I get the error...

      Can't locate object method "OnDestroy" via package "Tk::Menu::Cascade" at C:/Strawbery/perl/site/lib/Tk/Balloon.pm line 139.

      The difference is that I'm not even mapping the argument for -msg => as $_->[2] or $_->[-1] but just giving unmapped 'foo'. Any thoughts?

        Alas and alack, I read that we just can't do Balloons for Menus on Windows. Per the post here PerlMonks Friar lamprecht says, "Windows is special in that events over Menu windows are not passed to Tk so Balloon will not work here."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://951101]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2014-07-28 14:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (200 votes), past polls