in reply to Setting options in Tk::Optionmenu without the callback?

You can determine the current Tk widget being used to initiate the callbacks, and setup logic as needed.
sub show_choice{ my $caller = $Tk::widget; print 'caller-> ',$caller,"\n"; if( $caller =~ /^Tk::Menu.*/){ print "got: ", shift, "\n" }else{ return } }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: Setting options in Tk::Optionmenu without the callback?
by graff (Chancellor) on Aug 23, 2007 at 15:46 UTC
    This is clearly The Way It's Supposed To Be Done™. In fact, I can now make a really compact (and fairly coherent) idiom:
    sub my_optionmenu_callback { return unless ( $Tk::widget =~ /^Tk::Menu/ ); # do stuff... }
    Thank you -- knowing how to identify the caller like that is likely to simplify many things.