#! /usr/bin/perl use warnings; use strict; use Tk (); use Tk::Dialog (); my $mw = MainWindow->new(); my $frame = $mw->Frame()->pack(); use vars qw($Grey $Red); $Grey = '#aaaaaa'; $Red = '#ff0000'; my @fields = (); for my $j (1..20) { my @row = (); for my $i (1..10) { push (@row, $frame->Label(-text => ' ', -background => $Grey, -border => 1, -relief => 'sunken')); } # for push (@fields, \@row); my ($first, @other) = @row; $first->grid(@other); } # for j &SetColor(\@fields, 4,2, $Red); for my $j (1..3) { &SetColor(\@fields, 3,$j, $Red); } # for $mw->after('2000', sub { for my $j (1..3) { &SetColor(\@fields, 3,$j, $Grey); &SetColor(\@fields, 4,$j, $Red); } # for &SetColor(\@fields, 5,2, $Red); }); &Tk::MainLoop; # ------------------------------------------------------------ sub SetColor { my ($fields, $i, $j, $color) = @_; $fields->[$i]->[$j]->configure(-background => $color); } # SetColor