welle has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
I've been using popup menus for a while such as:
sub add_edit_popup { my ($mw, $obj) = @_; my $menu = $mw->Menu(-tearoff=>0, -menuitems=>[ [command=>'Start Term Info', -command=>[\&get_term_info_from_col_1 +_partial, $obj,]], '', [qw/command Copy/, -command=>['clipboardCopy', $obj,]], [qw/command Paste/, -command=>['clipboardPaste', $obj]], '', [command=>'Select All', -command=>[ sub { $_[0]->selectionRange(0, 'end'); }, $obj, ]], [command=>'Unselect All', -command=>[ sub { $_[0]->selectionClear; }, $obj, ]], ]); $obj->menu($menu); $obj->bind('<3>', ['PostPopupMenu', Ev('X'), Ev('Y'), ]); return $obj; }
I'd like to add a menu entry wiht suboption. In a classical menu, I obtain this with a simple:
my $frame_GUI = $mw->toplevel; my $menubar = $frame_GUI->Menu(-type => 'menubar'); $frame_GUI->configure(-menu => $menubar); my $menu_export_import = $menubar->cascade(-label => '~Import/Expo +rt', -tearoff => 0); my $menu_export = $menu_export_import -> cascade(-label =>"Export/ +Print", -underline => 0, -tearoff => 0); $menu_export->command(-label => 'MS Word)', -command => sub{expor +t_word()}); $menu_export->command(-label => "MS Excel)", -command => sub{expor +t_html()}); my $menu_import = $menu_export_import -> cascade(-label =>"Import" +, -underline => 0, -tearoff => 0); $menu_import->command(-label => 'MS Word)',-command => sub{import_ +word()}); $menu_import->command(-label => 'MS Excel', -command => sub{import +_excel()});
How can use the same structure of menu/submenus in the popup code above?
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk Popup menu
by zentara (Cardinal) on Mar 01, 2013 at 12:42 UTC | |
by welle (Beadle) on Mar 01, 2013 at 13:38 UTC | |
|
Re: Tk Popup menu
by thundergnat (Deacon) on Mar 01, 2013 at 15:16 UTC |