[Rd] Getting width of Tk text widget via tcltk

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Feb 28 17:26:40 CET 2005


"John Fox" <jfox at 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 at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-devel mailing list