Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I have a bit of code below which displays a list of options a user can choose. The problem is, when the user clicks on the menu button, the screen cannot display all options on the screen. Is there an option which allows a display similar to CGI's "More... ->" ? Thanks in advance. Stacy.
$category_menu_btn = $category_menu_fr -> Menubutton( -width => 29, -bg => $bg_clr, -relief => 'raised' ) -> pack(-side => 'left', -pady => '1'); my $category_menu = $category_menu_btn -> Menu( -tearoff => 0, ); $category_menu_btn -> configure(-menu => $category_menu); foreach $choice (@categories) { $category_menu -> add('command', -label => $choice, -command => sub { $last_category = $choice; $category_menu_btn -> configure( -text => "$last_category", ); $changes_have_been_made = 1; }, ); } # next $choice.

Replies are listed 'Best First'.
Re: Perl/Tk and excessive menu items
by kschwab (Vicar) on Jun 27, 2001 at 06:02 UTC
    You could implement this yourself with "Cascading Menus". Basically, you would create 2 menu widgets, the second as a child widget of the first.

    The first menu widget would then add it's last entry using the -menu option to specify the second menu widget to post as a cascading window.

    See the docs for Tk::Menu::Item and The CASCADE ENTRIES section of the Tk::Menu docs for more detail.

Re: Perl/Tk and excessive menu items
by Mungbeans (Pilgrim) on Jun 27, 2001 at 13:01 UTC
    I'd suggest using a scrolled hierarchical list (checkout perldoc tk::hlist). Cascading menus are good but there is still the risk that you will exceed the maximum number of entries.

    "The future will be better tomorrow."