use warnings; use strict; use Tk; my $page = MainWindow->new; $page->geometry('600x200'); # Create a frame ... my $suite_fr = $page->Frame->pack(-expand => 1, -fill => 'both'); # Add a label to the frame $suite_fr->Label(-text => 'Suite:')->pack(-side => 'left'); # create a Scrolled Listbox my $suite_lb = $suite_fr->Scrolled( 'Listbox', -exportselection => '0', -height => '7', -scrollbars => 'e', -selectbackground => 'gray80', -selectforeground => 'black', -selectmode => 'extended' )->pack(-side => 'left'); my $button = $page->Button( -text => ' Fill ', -command => sub{ fillbox($suite_lb) }, )->pack; MainLoop; sub fillbox{ my $self = shift; $self->packPropagate(1); my @list = 'X' x rand 80; # Populate the ListBox with the valid suites $self->insert(0, @list); $self->Subwidget("listbox")->configure(-width => 0); }