in reply to How to remove items from a cascade menu in Tk?

Tk documentation is often incomplete. Always look at the source and at the examples and on perltk.org and usually you'll find an answer. This works
use Tk; my $main = tkinit; my $menubar = $main->Menu(-type => 'menubar'); $main->configure(-menu => $menubar); my $menu_links = $menubar->cascade(-label => "Links", -tearoff => 0); $menu_links->command(-label => "Kill'em all", -command => sub{ $menu_links->menu->delete(2,5); }); $menu_links->separator(''); $menu_links->command(-label => 'test1', -command => \&sub1); $menu_links->command(-label => 'test2', -command => \&sub2); $menu_links->command(-label => 'test3', -command => \&sub3); MainLoop;

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: How to remove items from a cascade menu in Tk?
by Jester_yang (Initiate) on Jul 07, 2004 at 08:04 UTC
    Great! It works.
    It should be $menu_links->menu->delete(...);
    But I always try $menu_links->delete(...) directly, so it failed.
    Thanks a lot! ^_^