Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Change button color with Tk

by Discipulus (Canon)
on Nov 02, 2017 at 20:14 UTC ( [id://1202639]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Change button color with Tk
in thread Change button color with Tk

Hello PerlCowboy,

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*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1202639]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-23 23:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found