#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Pane; my $mw = MainWindow->new; $mw->geometry(q/600x400+100+100/); $mw->title("Test Script"); #need exportselection=>0 for using multiple selection boxes my %lbhash; # you want to use the listbox to hold your # data, so store the widget's actual object # with the name you want to give it my @choices = ('afg', 'dfg', 'erty', 'etc', 'foo','bar','wxyz'); # main Pane for all widget groups my $main_pane = $mw->Scrolled('Pane', -bg=>'black', -scrollbars=>'osoe', -sticky=>'nwse', )->pack(-expand=>1, -fill=>'both'); foreach my $choice(@choices){ # main frame for each widget set my $frame = $main_pane->Frame(-bg=>'lightblue') ->pack(-side => 'left', -expand=>1, -fill=>'y'); my $label = $frame->Label(-text=> $choice, -bg=>'hotpink') ->pack(-side=>'top'); $lbhash{ $choice }{'entry'}= $frame->Entry( -bg=>'lightyellow') ->pack(-side=>'top'); $lbhash{ $choice }{'widget'} = $frame->Scrolled('Listbox', -bg => 'white', -selectmode => 'extended', -exportselection=> 0 ) ->pack(-side=>'top', -expand=>1, -fill=>'y'); my @random_data; for(1..20){push @random_data ,int rand(100) } $lbhash{ $choice }{'widget'} ->insert( 'end', @random_data ); } $mw->Button( -text => "Selections", -command => sub{ foreach my $key( keys %lbhash ){ my @selects = $lbhash{ $key }{'widget'}->curselection; print "$key: "; my @inserts; foreach my $select (@selects){ push @inserts, $lbhash{ $key }{'widget'}->get($select); } my $insert_string = join " ", @inserts; $lbhash{ $key }{'entry'}->insert(0, $insert_string); } } )->pack( -side => 'bottom' ); $mw->Button( -text => "Done", -command => \&exit )->pack; MainLoop;