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

I need to have the option list and prompt the user to select "one or more" items from the list. List box is perfectly working fine for me except that i can NOT hide the option list. it displays all the items in the list on screen. my option list has around 30 items and i can;t afford the space as i have other widgets to populate. if i use scroll bar, i still need to show 2-3 items in the list which is okay but am looking for something like optionmenu where it shows just the first elecment. but the problem with this is, i can select only one item from the list. so i believe the best widget for me is Listbox, only thing is i need to hide all option but the first one. to be precise i am looking for Listbox functionality with Optionmenu appearance! is there a way to do it?

Replies are listed 'Best First'.
Re: ListBox Functionality
by dwm042 (Priest) on Mar 28, 2008 at 12:55 UTC
    I hate to be a spoiler but it's not clear to an outside reader what exactly you're referring to. A web page? Tk programming? Gtk programming? Can you give us a bit more context?

Re: ListBox Functionality
by boblawblah (Scribe) on Mar 28, 2008 at 13:09 UTC
    I'm assuming that you are working with Tk? You can create your own custom widget with the functionality you want. If you are not familiar with how to do this, then I suggest you do some reading. Here are a couple of links that will point you in the right direction.

    http://www.perltk.org/
    http://hell.org.ua/Docs/oreilly/

    Hope this helps.
Re: ListBox Functionality
by Anonymous Monk on Mar 28, 2008 at 12:53 UTC
    create X listboxes side by side? or have a detached listbox?
Re: ListBox Functionality
by zentara (Cardinal) on Mar 28, 2008 at 15:49 UTC
    You could try something like this: A Scrolled Pane filled with checkboxes. You may need to test the height of your font, to get the right height for the Pane, I just hardcoded in 45. Also remember, you need a minimum Pane height to show the scrollbar arrows, unless you make your own custom ones.
    #!/usr/bin/perl use warnings; use strict; use Tk; require Tk::Pane; my $mw = MainWindow->new; my $text = $mw->Scrolled("Text", -relief => 'sunken', -borderwidth => 2, -setgrid => 1, -height => 10, -width => 20, -scrollbars => 'oe')->pack(); $mw->Label(-text=>'Select from choices below')->pack(); my $pane = $mw->Scrolled('Pane', -height => 45, -bg => 'lightgreen', -scrollbars=>'osoe', )->pack(-fill => 'x',-expand=>'yes'); for my $choice(1..30){ my $b1 = $pane->Checkbutton( -text => $choice, -relief => 'flat', -command=> sub{ $text->insert('end',"$choice\n"); }, )->pack(-side => 'top', -pady => 1 ,-anchor => 'w'); } $pane->focus; MainLoop;

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: ListBox Functionality
by Anonymous Monk on Mar 28, 2008 at 12:58 UTC
    What is option list?