#!/usr/bin/perl use Tk; use Tk::TableMatrix; my $mw = MainWindow->new; my (%wg, %hashv); print "Filling Array...\n"; my ($rows,$cols) = (10, 10); foreach my $row (0..($rows-1)){ foreach my $col (0..($cols-1)){ $hashv{t1}{"$row,$col"} = 2*$row + 3*$col; $hashv{t2}{"$row,$col"} = 2*$row + 3*$col + 100; } } print "Creating Table t1\n"; $wg{t1} = $mw->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -width => 10, -height => 10, -titlerows => 1, -titlecols => 1, -variable => \%{$hashv{t1}}, -coltagcommand => \&colSub1, -browsecommand => \&tbmx_browse_cmd_t1, -colstretchmode => 'last', -rowstretchmode => 'last', -selectmode => 'extended', -selecttitles => 0, -drawmode => 'slow', -scrollbars=>'se' ); $wg{t1}->grid(-row => 0, -column => 0); # set the column widths $wg{t1}->colWidth(0 => 2, 1 => 4, 2 => 6, 4 => 8); # defining tags $wg{t1}->tagConfigure('dis', -state => 'disabled', -bg => 'yellow'); $wg{t1}->tagConfigure('red', -bg => 'red'); $wg{t1}->tagCell('dis',"1,1"); $wg{t1}->tagCell('dis',"1,2"); $wg{t1}->tagCell('dis',"1,3"); $wg{t1}->tagCell('red',"3,1"); $wg{t1}->tagCell('red',"3,2"); $wg{t1}->tagCell('red',"3,3"); #===================================================== # # tbmx_browse_cmd_t1 # # browse command for table matrix t1 # #===================================================== sub tbmx_browse_cmd_t1() { my ($previous_index, $actual_index) = @_; my ($row, $col) = split ',', $actual_index; print "[tbmx_browse_cmd_t1] index actual <$actual_index> previous <$previous_index> row <$row> col <$col>\n"; } Tk::MainLoop;