G'day jbuck,

I'm running Perl (v5.34.0) built for cygwin-thread-multi and Tk 804.036

Firstly, I changed the shebang line to #!/usr/bin/env perl and used your suggested options: my $txt = "Col $col"; and $pane->Label(...)->pack(...);. Other than that, I used exactly the same code that you posted.

Labels appeared correctly up to "Col 697"; the next was truncated to "Col 69". This appears to mirror what you described. There were no errors, warnings, or other messages emitted.

Your assumption about "$col" vs. "Col $col" is not correct; although, I may have misinterpreted what you said. There is no actual resizing to accomodate the "Col " prefix. When I changed 1..1000 to 1..2000 and used "$col", labels up to "1212" appeared correctly then the next was truncated to "121" (given that the padding and borders haven't changed, this almost doubling of displayed labels is in keeping with what I roughly expected).

While this won't change the display issue you've encountered, following the Tk::Pane documentation:

$pane = $mw->Scrolled("Pane", ...); # add widget(s) to $pane here $pane->pack;

will make the GUI render a lot more quickly. I didn't time it but it was noticeably faster (perhaps x5 or x10).

If your question was purely of an academic nature — i.e. you found something and just asked about it — I would just note the limitation and move on. You could raise a bug report that either requests a fix or an addition to the doco which describes the limitation.

If you genuinely have a requirement for a GUI that needs to render 1,000 columns, you should pick another widget. Without knowing what that application might be, I can really only suggest looking for widgets with "List", "Table" or similar in their names.

Amongst other things, I work with biological data which can be huge (gigabytes) and is often in a CSV format with more than 1,000 columns. It occurred to me that you might be doing something similar. I've never had a requirement to present such data in a Tk GUI; however, if I did, Tk::TixGrid could be a useful option. Here's an example:

#!/usr/bin/env perl use strict; use warnings; use Tk; use Tk::TixGrid; my $mw = MainWindow::->new(); $mw->geometry('500x500'); my $tgrid = $mw->Scrolled(TixGrid => -scrollbars => 'se') ->pack(-side => 'left', -fill => 'both', -expand => 1); $tgrid->configure(-formatcmd => sub { my ($type, @coords) = @_; $tgrid->format(grid => @coords, -bg => '#000000', -bd => 1); return; }); my $dat = 'a'; my @csv = map ["Col $_", ($dat++) x 999], 1 .. 1000; for my $c (0 .. $#csv) { for my $r (0 .. $#{$csv[0]}) { $tgrid->set($c, $r, -itemtype => 'text', -text => $csv[$c][$r] +); } } MainLoop;

The data is highly contrived and is only intended as an example. It does show 1,000 columns and 1,000 rows (1,000,000 cells). I haven't used that module previously and was pleasantly surprised at how quickly it rendered. Of course, with substantially more data, there could still be some rendering limit. Anyway, it was purely guesswork with regards to your requirements and a fun diversion for myself.

— Ken


In reply to Re: Tk::Pane widget size limit? by kcott
in thread Tk::Pane widget size limit? by jbuck

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.