some tips (i don't know what they are)
#!/usr/bin/perl -- use strict; use warnings; use Tk; use Data::Dump qw/ dd pp /; my $mw = tkinit(qw/ -width 30 -height 30 /); my $t = $mw->Text->pack(qw/ -expand 1 -fill both /); $t->insert('end', q{"There must be some kind of way out of here," Said the joker to the thief. "There's too much confusion, I can't get no relief. Businessmen, they drink my wine, Plowmen dig my earth. None of them along the line Know what any of it is worth." "No reason to get excited," The thief he kindly spoke. "There are many here among us Who feel that life is but a joke. But you and I, we've been through that, And this is not our fate. So let us not talk falsely now, The hour is getting late." All along the watchtower, Princes kept the view, While all the women came and went -- Barefoot servants too. Outside in the cold distance, A wildcat did growl. Two riders were approaching, and The wind began to howl. http://www.reasontorock.com/tracks/watchtower.html }); $t->tagConfigure('yellow', -background => "yellow"); my $b = $mw->Button( -text => 'dlineinfo', -command => [ sub { my( $mw, $t ) = @_; ffd( $mw, $t, qw/ 1.20 2.12 12.30 15.28 22.16 24.20 +/); }, $mw, $t, ], )->pack( -before => $t ); $b->focus; #~ use Tk::WidgetDump; $mw->WidgetDump; MainLoop(); sub ffff { my( $mw, $t ) = @_; my $geom = $mw->geometry; my( $trooty, $theight ) = ( $t->rooty, $t->height ); my $ttaily = $trooty + $theight; "mw(geo{$geom}) trooty($trooty)+theight($theight)= $ttaily"; } sub ffd { my( $mw, $t ) = splice @_,0,2; print "\n", ffff( $mw, $t ), "\n"; for my $index( @_ ){ $t->tagAdd('yellow', "$index wordstart", "$index wordend", ); my @aline = qw/ lTx lTy wpx hpx bsT /; my @dline = $t->dlineinfo("$index wordstart"); my $theword = $t->get( "$index wordstart", "$index wordend" ); if( not @dline ){ print "($index $theword) SKIP not visible\n"; next; } printf "%-10s %-10s %5s %-5s %5s %-5s %5s %-5s %5s %-5s %5s %- +5s\n", $index, $theword, map { $aline[$_], $dline[$_] } 0 .. $#aline, ;;;;; my @bbLine = qw/ lTx lTy lTw lTh /; my( @bbLineStart ) = $t->bbox("$index linestart" ); my( @bbLineEnd ) = $t->bbox("$index lineend" ); printf "%-10s %-10s %5s %-5s %5s %-5s %5s %-5s %5s %-5s %5s %- +5s\n",, $index, 'end', ( map { $bbLine[$_], $bbLineEnd[$_] } 0 .. $#bbLine,), ('') x 2, ;;;;; printf "%-10s %-10s %5s %-5s %5s %-5s %5s %-5s %5s %-5s %5s %- +5s\n", $index, 'start', ( map { $bbLine[$_], $bbLineEnd[$_] } 0 .. $#bbLine,), ('') x 2, ;;;;; print "\n"; } #~ my $width = (200,400,600)[rand 2]; #~ $mw->geometry( $width."x$width"); } __END__

In reply to Re: Query the height of Tk::Text widget with word wrap by Anonymous Monk
in thread Query the height of Tk::Text widget with word wrap by elef

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.