Adding
to the end does the trick.... which pokes the TK engine and says "Hey, set the value to THIS". Even though the variable already contained the right value, I guess TK needs to have some sort of event to know it needs to update. So the corrected code, that now works, looks like:$platformDropdown -> configure( -textvariable => \$platformChoice );
my %solutionMatrix; my $defaultPlatform = "Mod1"; $solutionMatrix{"Mod1"} = [ 'a','b','c' ]; $solutionMatrix{"Mod2"} = [ 'q' ]; my $platformDropdown = $selectionFrame -> Optionmenu ( -textvariab +le => \$platformChoice, -indicatoron => 1 ) -> pack( -side => "left") +; # --- now populate the options in the platform and customer dr +opdown list, # which is in the hash of arrays, %solutionMatrix foreach my $platform ( sort keys %solutionMatrix ) { # $platform is a choice for the platform dropdown # @{$solutionMatrix{$platform} is an array of solutions fo +r the customer dropdown $platformDropdown -> addOptions([$platform=>$platform]); } $platformChoice = $defaultPlatform; # set default $platformDropdown -> configure( -textvariable => \$platformCho +ice );
In reply to Re^2: Tk Optionmenu - how to set the default selection
by Minok
in thread Tk Optionmenu - how to set the default selection
by Minok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |