in reply to Re^2: Change button color with Tk
in thread Change button color with Tk
you can use a brutal method like storing all buttons into an hash:
my $mw = MainWindow->new; my %buttons; for (1..9){ $buttons{$_} = $mw->Button(-text=>"Button $_",-command=>[\& +colorize,$_])->pack; } MainLoop; sub colorize{ $buttons{$_[0]}->configure(-bg=>'yellow'); print $buttons{$_[0]}->cget('-text')," button is yellow n +ow\n"; }
Or you can use Canvas tagging facility to select the current one
L*
|
|---|