in reply to Setting options in Tk::Optionmenu without the callback?
You can prevent the callback from being triggered by setting the variable to the first item of @newoptions before changing the options.
sub change_ops { my $op = shift; my $var = $op->cget('-textvariable'); my @newoptions = map { ++$. } ( 0 .. 3 ); my ($prev) = (grep {$_ eq $$var} @newoptions) || ''; $$var = $newoptions[0]; $op->configure( -options => \@newoptions ); $$var = $prev; }
|
|---|