Are you trying to achieve this?
#!/usr/bin/perl use strict; use warnings; use feature qw( state ); use Tk; my ( @bHits, @rHits ); my ( @bList, @rList ); state $turn = 0; my $mw = MainWindow->new( -title => 'Test Grid!' ); $mw->geometry( '1000x400+200+50' ); $mw->resizable( 0, 0 ); $mw->Label( -text => 'Test Grid', -foreground => 'black', )->pack( -side => 'top', -expand => '0', ); my $mw_switch_b = $mw->Button( -text => 'Switch', -command => \&toggleButtons, )->pack; my $mw_exit_b = $mw->Button( -text => 'Exit', -command => sub { exit } )->pack; my ( $blueFrame, $redFrame, $blHitFrame, $rdHitFrame ); $blueFrame = $mw->Frame; $redFrame = $mw->Frame; ### Blue Grid for my $row ( 0 .. 9 ) { for my $col ( 0 .. 9 ) {; $blueFrame->Button( -text => $col . $row, -background => 'light blue', -command => \&toggleButtons , )->grid( -row => $row, -column => $col ); } } ### Red Grid for my $row ( 0 .. 9 ) { for my $col ( 0 .. 9 ) { $redFrame->Button( -text => $col . $row, -background => 'gray', -command => \&toggleButtons, -state => 'disabled', )->grid( -row => $row, -column => $col ); } } $blueFrame->pack( -side => 'left', -padx => '10' ); $redFrame->pack( -side => 'right', -padx => '10' ); @bList = $blueFrame->gridSlaves(); @rList = $redFrame->gridSlaves(); MainLoop; sub toggleButtons { my $bg = 'light blue'; for my $list (\@bList, \@rList) { my ($state, $background) = 'disabled' eq $list->[0]->cget('-st +ate') ? ('normal', $bg) : qw/disabled gray/; for my $button (@$list) { $button->configure(-state => $state, -background => $background); } $bg = 'indian red'; } }

In reply to Re: Perl/Tk button color refresh using repeat... by choroba
in thread Perl/Tk button color refresh using repeat... by dbuckhal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.