Re: Counting text pixels



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
.



Relevant Pages

  • Re: Text Setting on IE 6 wont stay
    ... I know it's not much help, but, you can use the mouse scroll to change the ... > of these settings are what I normally run under... ... >> The font size in IE keeps changing. ... >> Windows will ask you to confirm the change, ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Page viewing settings follow-up
    ... I no longer have to scroll across the bottom to read pages. ... desktop icons were initially tiny. ... This was after I increased the font size to "larger", 125% of normal size, ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Rich Text Flip Horizontal (Mirror)
    ... i am making an universal teleprompter, where user can load any font etc. ... i wanted to know the possiblity to flip the RTF in one pass. ... scroll bar. ...
    (microsoft.public.vstudio.general)
  • Re: !Google Toolbar Request
    ... you use the scrollbar to scroll the menu. ... move up of its own accord when you approach the bottom of the screen? ... in practical terms almost any menu that is taller than the ... (The only semi-valid exception to this I can think of is font menus - ...
    (comp.sys.acorn.programmer)
  • Re: Two Questions
    ... where the character seems to stick up above ... I can get neither the tabbed panes nor scrolled pane ... a scroll bar in, but it wouldn't auto-size to the frame. ... > poor eyesight and need to use a font that is larger than that used by ...
    (comp.lang.java.gui)