Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Auto-adjust row height to line wrap in Tk-Tablematrix by elef

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-03-19 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found