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

In reply to Re: Non editable cells in Tk::TableMatrix by zentara
in thread Non editable cells in Tk::TableMatrix by ravishi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.