I am using Tk::TableMatrix and Perl to create a GUI displaying a big table. I have information for usually only one row per column, sometimes two rows. Here is a sample code which shows what I am currently doing.
#!/usr/bin/perl use Tk; use Tk::TableMatrix; use strict; use warnings; my $mw = MainWindow->new; my $table = $mw->Scrolled("TableMatrix", -resizeborders=>'non +e', -titlecols => 1, -rows => 6, -colstretchmode=>'al +l', -cols => 1, -cache => 1, -scrollbars => "osoe +"); for(my $col = 1; $col < 500; $col++) { $table->insertCols("$col.0", 1); my $button = $table->Button(-text => "$col enabled", -command +=> sub {$table->see("0,300"); + } ); #initialy fill table with blank windows. Section to improve my $blank = $table->Label(-text => "", -background => 'white', + -cursor => ['left_ptr']); $table->windowConfigure("0,$col", -window => $blank, -sticky = +> 'nsew'); $blank = $table->Label(-text => "", -background => 'white', -c +ursor => ['left_ptr']); $table->windowConfigure("1,$col", -window => $blank, -sticky = +> 'nsew'); $blank = $table->Label(-text => "", -background => 'white', -c +ursor => ['left_ptr']); $table->windowConfigure("2,$col", -window => $blank, -sticky = +> 'nsew'); $blank = $table->Label(-text => "", -background => 'white', -c +ursor => ['left_ptr']); $table->windowConfigure("3,$col", -window => $blank, -sticky = +> 'nsew'); $blank = $table->Label(-text => "", -background => 'white', -c +ursor => ['left_ptr']); $table->windowConfigure("4,$col", -window => $blank, -sticky = +> 'nsew'); $blank = $table->Label(-text => "", -background => 'white', -c +ursor => ['left_ptr']); $table->windowConfigure("5,$col", -window => $blank, -sticky = +> 'nsew'); #fill each column with a button with random row placement my $row = int(rand(5)); $table->windowConfigure("$row,$col", -window => $button, -stic +ky => 'nsew'); } #set row titles $table->set("0,0", "Col 1"); $table->set("1,0", "Col 2"); $table->set("2,0", "Col 3"); $table->set("3,0", "Col 4"); $table->set("4,0", "Col 5"); $table->set("5,0", "Col 6"); $table->pack(-expand => 1, -fill => 'both'); MainLoop;
Is there a more efficient way of setting every cell to just a blank window and not an editable field. I looked in the perldoc pages and tried using -state => disabled but that didn't seem to let me use -insertRows and -insertCols.

I have found the TableMatrix module to be the best module for what I want compared to Tk::Table, Tk::Grid, and Tk::Hlist so I would not like to switch modules.


In reply to 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.