I'm using line wrap to display variable length text in Tk::TableMatrix. It works fine, lines are wrapped as needed, and the line wrap adjusts automatically when the columns are resized.
The problem is that row height can only be set manually. I can set all rows to be 2 lines in height, but I can't set them to be as high as it takes to display all text in each row. As a result I either get a bunch of text that's not visible, or an awful lot of wasted empty space.
If I were to use a monospace font and set a fixed column width, maybe I could write some code that calculates the height required for each row and sets it, but I want to avoid fixed column widths if at all possible.
Is there a solution? My googling turned up no answers except this, which is for TkTable in Tcl/Tk and I can't make much sense of it:
set maxr [.table cget -rows]
set maxc [.table cget -cols]
for {set r 1} {$r < $maxr} {incr r} {
set maxh 1
for {set c 0} {$c < $maxc} {incr c} {
if {[set n [llength [split [.table get $r,$c] \n]]]>1 && $maxh<$n
+} {
set maxh $n
}
}
.table height $r $maxh
}
From http://wiki.tcl.tk/1877
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.