in reply to Currently selected TK widget.
There are a few variations on the callback syntax. You could also doforeach my $button ( @buttons ) { ......... ........ # Add a button widget $frame->Button( -anchor => 'nw', -text => "change " . $button, -command => [\&print_button_label, $button], )->pack( -side => 'left', -anchor => 'w', -padx => 2 ); } ############################################### sub print_button_label{ my $button = shift; print "button\n"; }
-command => sub { print_button_label( $button ) },
You could also use the 'current' tag trick, where you bind a <1> press to a sub which gets the currently active widget, then use cget on the widget, to find it's name or other property; but you will usually see it as I shown above.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Currently selected TK widget.
by Butch (Novice) on Apr 11, 2006 at 11:52 UTC |