The documentation seems to imply that the variable is tied somehow so changes will be automatically applied, but I don't see code to do that anywhere. It looks like if you replace your line
$selectVendor->configure(-variable => \$vsel);with
$selectVendor->set_option( $vsel, $vsel, $vsel );it seems like it does what I think you want.
See test code below:use warnings; use strict; use Tk; use Tk::Optionbox; my $newTop = MainWindow->new; my $vsel; my @options = ( qw/ This That Amazon Th'other too many to fit on the s +creen/); my $selectVendor = $newTop->Optionbox(-text=>'Vendor', -command => \&sayit, -variable=> \$vsel, # -font=>$variableFont, -options=> [@options], -rows =>15, )->pack(-side=>'left'); $vsel = 'Amazon'; $selectVendor->set_option( $vsel, $vsel, $vsel ); MainLoop; sub sayit { print $_[0], "\n"; }
In reply to Re: Tk::Optionbox default
by thundergnat
in thread Tk::Optionbox default [Solved]
by jinnicky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |