Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Tk::Table is slow, but I tried with 40 X 5 table, it seems "okay" to me.

I don't know what widget you used for each cell. Some widgets are lighter than others. As you said an alternative is to draw on Canvas, I assume your table is readonly, in this case, Label is good enough for your cells. You can use Button as row and column header. (Even if your cells are writable, most likely Entry is good enough.)

Below is the code I tried, it does take around 10 seconds to come up, but after that it responses to row or column scroll quite okay. (I think I should mention that my computer is 7 years old and really slow)

use Tk; use Tk::Table; use Data::Dumper; use strict; my $mw = MainWindow->new; $mw->geometry("600x250"); my $table = $mw->Table(-rows => 40, -columns => 5, -scrollbars => "se", -fixedrows => 1, -fixedcolumns => 1, -takefocus => 1)->pack; foreach my $col (1 .. 5) { my $col_header = $mw->Button(-text => "Column " . $col); $table->put(0, $col, $col_header); } foreach my $row (1 .. 40) { my $row_header = $mw->Button(-text => "Row " . $row); $table->put($row, 0, $row_header); foreach my $col (1 .. 5) { my $cell = $mw->Label(-width => 10, -text => $row * $col, -bor +derwidth => 1, -relief => "solid"); $table->put($row, $col, $cell); } } MainLoop;

I do have a thought triggered by your OP, to create something like Tk::TableLite. The biggest parts I want to improve are:

  1. instead of having one widget for each cell, only have one widget for each cell in the viewport. By doing this, the weight of the GUI, is no longer related to the size of the data, and it is predetermined.
  2. Scroll should not scroll widgets (cells), widgets are fixed. Scroll only scrolls a sliding window against the data, and the data in the sliding window will be used to reset the text displayed in cells.

    In reply to Re: Tk::Table too slow. Alternatives ? by pg
    in thread Tk::Table too slow. Alternatives ? by spurperl

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

    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
      <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2022-12-07 23:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found