in reply to Non editable cells in Tk::TableMatrix

If you want to use a blank window, instead of an empty-colored cell, I don't think you can do much else than what you are doing now. Creating a window is needed for each and every cell. All I can offer is some code syntax improvements. One is to use the variable option to build your data, this can be useful in importing alot of data. The second is to loop thru the table only once, by nested looping. My code dosn't seem any faster than yours, but it's easier to read and see what is happening. Your big slowdown is in creating all those Labels and Button widgets.

If you are not stuck on the idea of the nice window look, you could use the tag mechanism to make a disabled tag, and color it someway.

#!/usr/bin/perl use Tk; use Tk::TableMatrix; use strict; use warnings; my $arrayVar = {}; print "Filling Array...\n"; my ($rows,$cols) = (6, 500); foreach my $row (1..$rows){ $arrayVar->{"$row,0"} = "$row"; } foreach my $col (1..$cols){ $arrayVar->{"0,$col"} = "$col"; } my $mw = MainWindow->new; my $table = $mw->Scrolled( "TableMatrix", -resizeborders => 'none', -titlecols => 1, -rows => 7, -colstretchmode => 'all', -cols => 501, -cache => 1, -scrollbars => "osoe", -variable => $arrayVar, ); foreach my $col(1..500) { foreach my $row(1..7) { my $blank = $table->Label( -text => "", -background => 'white', -cursor => [ 'left_ptr' ] ); if ( $row == 3 ){ $table->set("$row,$col",42); next } if( $row == 4 ){ my $button = $table->Button( -text => "$col enabled", -command => sub { $table->see( "0,300" ); } ); $table->windowConfigure( "$row,$col", -window => $button, -stick +y => 'nsew' ); }else{ $table->windowConfigure( "$row,$col", -window => $blank, -sticky + => 'nsew' ); } } } $table->pack( -expand => 1, -fill => 'both' ); MainLoop;

I'm not really a human, but I play one on earth Remember How Lucky You Are