#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::TableMatrix; my $mw = MainWindow->new; my $arrayVar = {}; print "Filling Array...\n"; my ($rows,$cols) = (10, 10); foreach my $row (0..($rows-1)){ foreach my $col (0..($cols-1)){ $arrayVar->{"$row,$col"} = "$row,$col"; } } print "Creating Table...\n"; sub colSub{ my $col = shift; return "OddCol" if( $col > 0 && $col%2) ; } sub rowSub{ my $row = shift; return "Oddrow" if( $row > 0 && $row%2) ; } my $t = $mw->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -width => 6, -height => 6, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -coltagcommand => \&colSub, -browsecommand => \&coloring, -colstretchmode => 'last', -rowtagcommand => \&rowSub, -rowstretchmode => 'last', -selectmode => 'extended', -selecttitles => 0, -drawmode => 'slow', -scrollbars=>'se', -relief => 'ridge', -selectmode => 'extended', -selecttype=>'row', ); # Color definitions here: $t->tagConfigure('active', -bg => 'lightyellow', -fg => 'red', -relief => 'sunken'); $t->pack(-expand => 1, -fill => 'both'); $t->focus; $t->configure (-state=>'disabled'); Tk::MainLoop; sub coloring { print "COLORING SELECTED ROW...\n"; my ($previous_index, $actual_index) = @_; my ($row, $col) = split ',', $actual_index; $t->tagRow('active',$row); }