Hi again. Just to show you the problem you will run into with alot of widgets, test this snippet. It runs fine as is (40 rows), but change the rows to 40000, and compare it's performance to the TableMatrix::Spreadsheet snippet. ( Hint: you will get 99% cpu usage for a minute or two or more!)
#!/usr/bin/perl use Tk; use Tk::Table; use Data::Dumper; use strict; # by pg of perlmonks.org # As you can see, it is very easy to set/get the cell values, # and modification to data is automatically reflected on screen # (you don't need to do anything). If you only want to display # data, but not editing, replace Entry with Label. my ($row, $col); #data, in your case, come from database my @cell_vars; foreach $row (0 .. 9) { my @row_vars; foreach $col (0 .. 9) { push @row_vars, $row * $col; } push @cell_vars, \@row_vars; } #presentation my $mw = MainWindow->new; $mw->geometry("600x250"); my $table = $mw->Table(-rows => 9, -columns => 9, -scrollbars => "se", -fixedrows => 1, -fixedcolumns => 1, -takefocus => 1)->pack; foreach $col (1 .. 9) { my $col_header = $mw->Button(-text => "Column " . $col); $table->put(0, $col, $col_header); } # foreach my $row (1..40000){ foreach $row (1 .. 40) { my $row_header = $mw->Button(-text => "Row " . $row); $table->put($row, 0, $row_header); foreach $col (1 .. 9) { my $cell = $mw->Entry(-width => 10, -textvariable => \$cell_var +s[$row][$col]); $table->put($row, $col, $cell); } } #manipulate data $cell_vars[5][6] = "foo"; MainLoop;

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: repeating Tk widgets for data editing by zentara
in thread repeating Tk widgets for data editing by Woodman

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.