#!/usr/bin/perl use strict; use Tk; use Tk::BrowseEntry; my $mw = MainWindow->new; # Mainwindow: sizex/y, positionx/y $mw->geometry("200x200+100+120"); my $shortlist = [qw(a b c d)]; my $longlist = [qw(a b c d e f g h i j k l m n o p r s t u w)]; &create_dropdown($mw); MainLoop; sub create_dropdown { my $mother = shift; # Create dropdown and another element which shows my selection my $dropdown_value; my $dropdown = $mother->BrowseEntry( -label => "Label", -variable => \$dropdown_value, -autolimitheight => 1 )->pack; $mother->Button( -text => "Short List", -command => sub{ $dropdown->configure(-choices => $shortlist)})->pack; $mother->Button( -text => "Long List", -command => sub{ $dropdown->configure(-choices => $longlist)})->pack; # Populate dropdown with values $dropdown->configure(-choices => $longlist, -autolimitheight => 1); return; }