Re: Counting text pixels
- From: Arndt Roger Schneider <roger.schneider@xxxxxxxxx>
- Date: Wed, 27 Aug 2008 18:56:19 +0200
S M Ryan schrieb:
I want to adjust the size of text widget so that all the text is vertically visible for the current width, and no extra space. The information obviously available or the text widget couldn't scroll. However it seems impossible to prise it out of the 8.4 versions.
It looks like the 8.5 has $t count -ypixels 1.0 end, but does that actually count the entire vertical span, including scrolled off sections? Would this size $t to fit exactly
canvas $c ...
text $t ...
...
$c create window -window $t -tags kumquat ...
...
$c itemconfigure kumquat -height [
$t count -ypixels 1.0 end
]
The width of Text can be measured without a
window, what you need is a font object!
font create meta -family helvetica -size 11
font measure meta Test
--> gives the width of "Test" in pixel
You have to calculate the height by hand!
height:= lines * [tk scaling]* <font size>
Or: In case of a canvas use bbox.
..c bbox my_textitem
--> left top right bottom
-roger
.
- References:
- Counting text pixels
- From: S M Ryan
- Counting text pixels
- Prev by Date: Re: Regarding TCL Packages
- Next by Date: Re: Counting text pixels
- Previous by thread: Counting text pixels
- Next by thread: Re: Counting text pixels
- Index(es):
Relevant Pages
|