Daily Archives: February 11, 2005

Cascading Menus in Perl/Tk

Could not remember how to do cascading submenus in Perl/Tk the “old” way and googled examples were very hard to grok, but after an hour+ of t&e, here’s what works:

my $someMenubtn = $frame->Menubutton(
-text => ‘TopMenuItem’, -underline => 0, -takefocus => 1);

$someMenubtn->cascade(-label => ‘Menuitem_x’, -menuitems => [
[Button => ‘Submenuitem_1’, -underline => 12, -command => sub { } ],
[Button => ‘Submenuitem_2’, -underline => 12, -command => sub { } ],

]);