From p.dalgaard at biostat.ku.dk  Mon Feb 28 17:26:40 2005
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Mon Feb 28 17:32:32 2005
Subject: [Rd] Getting width of Tk text widget via tcltk
In-Reply-To: <20050228162539.RTUM1899.tomts13-srv.bellnexxia.net@JohnDesktop8300>
References: <20050228162539.RTUM1899.tomts13-srv.bellnexxia.net@JohnDesktop8300>
Message-ID: <x2ekf0hcqn.fsf@biostat.ku.dk>

"John Fox" <jfox@mcmaster.ca> writes:

> Dear Peter,
> 
> (as.numeric(tkwinfo("width", .output$ID))
>     - 2*as.numeric(tkcget(.output, borderwidth=NULL)) - 2)/
>     as.numeric(tkfont.measure(tkcget(.output, font=NULL), "0"))
> 
> (for the text widget .output) appears to do the trick (note, subtracting 2
> rather than 4).

Hmm, that's odd. I needed the 4. Beware that Tcl does integer division
(%/%). Did you round() or floor() the result? 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] Getting width of Tk text widget via tcltk
Peter Dalgaard