#!/usr/bin/perl -w use strict; use Tk; use Tk::BrowseEntry; my @typeChoices = qw(1553 1554); my $paramType = $typeChoices[0]; my $mw = MainWindow->new(); my $be = $mw->BrowseEntry( -label => 'List Test', -choices => [@typeChoices], -variable => \$paramType, -browsecmd=>sub{ if ($paramType eq '1553'){ func1553();} elsif($paramType eq '1554'){ func1554();} } )->pack(); $mw->Button(-text=>'simulate file setting', -command => sub{ $paramType = set_type(); # add a new type by pushing it into # the array @typeChoices push @typeChoices, time; #move type to first position in list if desired for(1..$#typeChoices){ if( $paramType == $typeChoices[0]){last} push (@typeChoices,shift(@typeChoices)); #circular list } $be->configure( -choices => [@typeChoices], ); })->pack(); MainLoop; sub func1553{ print "1553 running\n" } sub func1554{ print "1554 running\n" } sub set_type{ my $rand_num = int(rand(1) + .5); if( $rand_num == 0){ return 1553 }else{ return 1554 } }