use warnings; use strict; use Tk; use Tk::TableMatrix::Spreadsheet; $| = 1; my $mw = tkinit; my $NumCols = 50; our $tmVar = {}; our $TM_Table = $mw->Scrolled('Spreadsheet', -variable => $tmVar, -sparsearray=>1, -titlerows => 1, -titlecols => 1, -scrollbars => 'se', -selectmode => 'extended', -rows=>1, -cols=> $NumCols, -resizeborders => 'both', -wrap=>1, -bd=>1, -cache=>0, -selecttitle=>1, -colstretchmode => 'none', -rowstretchmode => 'none', -rowheight => 1, -drawmode=>'fast')->pack(-expand=>1,-fill=>'both'); $mw->Button(-text=> 'Fill Tablematrix', -command => \&FillTM)->pack; $mw->Button(-text=> 'Clear Tablematrix', -command => \&ClearTM)->pack; #Top row $TM_Table->set("0,$_", $_) for (0..$NumCols-1); MainLoop; sub FillTM { my $Rows = 5000; $TM_Table->insertRows("0.0", $Rows); for my $Row (1..5000) { $mw->update if (not $Row % 500) xor $TM_Table->see("$Row,0"); for (0..$NumCols-1){ $TM_Table->set("$Row,$_",qw(111 222)[int rand 2] x 50 ); } } } sub ClearTM { #$TM_Table->deleteRows('-keeptitles', '0.0', $TM_Table->cget(-rows)); $TM_Table->deleteRows( '0.0', $TM_Table->cget(-rows)); $TM_Table->clearAll('0,0','end'); undef $tmVar; }