One way to do it, would be to have listboxes taking the output of the optionmenu.
#!/usr/bin/perl use warnings; use strict; use Tk; my @fruits = ("apple","pear","orange","starfruit","pineapple"); my @veggies = ("tomato","chard","spinach","beans","radish"); my @treats = ("chocolate","icecream","raspberries","pretzels","chips") +; my %hash = ( fruits=> \@fruits, veggies => \@veggies, treats=> \@treats); my @sel = keys %hash; my $mw = MainWindow->new(); my $choice = 'apple'; my $selection = ''; my $bframe1= $mw->Frame()->pack(-side => "bottom"); my $bframe= $mw->Frame()->pack(-side => "bottom"); my $list = $bframe->Scrolled('Listbox', -listvariable => \@sel, -scrollbars=>'osoe', )->pack(-side=>'left'); my $list1 = $bframe->Scrolled('Listbox', # -listvariable => \@sel, -scrollbars=>'osoe', )->pack(-side=>'right'); my $om = $mw->Optionmenu( -options=> \@sel, -textvariable=>\$choice, -width=>'25', -command => sub{ @sel = @{$hash{$choice}} }, )->pack(-expand => '1'); $list->bind( '<ButtonRelease-1>', sub { update( $_[0], $list1 ) } ); $list1->bind( '<ButtonRelease-1>', sub { $selection = $_[0]->get( $_[0]->curselection ); # print "$sel\n"; } ); my $sel_label = $bframe1->Label( -textvariable => \$selection)->pack(); MainLoop; sub update { my ( $src, $dst ) = @_; my $index = $src->curselection; if ($index) { $dst->delete( 0, 'end' ); my $value = $src->get($index); foreach my $type(1..100){ $dst->insert( 'end', $value.$type ); } } }

I'm not really a human, but I play one on earth Remember How Lucky You Are

In reply to Re: PERL/TK Optionmenu problem by zentara
in thread PERL/TK Optionmenu problem by bhushanbits2005

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.