From jfox at mcmaster.ca  Mon Feb 28 15:05:03 2005
From: jfox at mcmaster.ca (John Fox)
Date: Mon Feb 28 15:05:13 2005
Subject: [Rd] Getting width of Tk text widget via tcltk
Message-ID: <20050228140503.YGVI1919.tomts22-srv.bellnexxia.net@JohnDesktop8300>

Dear list members,

Is it possible via a suitable tcltk command to get the *current* width, in
characters, of a Tk text widget that has been resized with the mouse? In the
following code, the reported width of the text widget doesn't change, even
though it has been resized. I can, however, get the current width in pixels:

> library(tcltk)
> top <- tktoplevel()
> textWindow <- tktext(top, bg="white", height=20, width=80, wrap="none")
> tkgrid(textWindow, sticky="news")
<Tcl>  
> tkgrid.rowconfigure(top, 0, weight=1)
<Tcl>  
> tkgrid.columnconfigure(top, 0, weight=1)
<Tcl>  
> tkcget(textWindow, width=NULL)
<Tcl> 80 
> tkwinfo("width", textWindow$ID)
<Tcl> 486 
 
> # resize window with mouse
> tkcget(textWindow, width=NULL)
<Tcl> 80 
> tkwinfo("width", textWindow$ID)
<Tcl> 743 

I could convert pixels to characters, but wonder whether I can get the
latter directly.

Any help would be appreciated.

John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox


[Rd] Getting width of Tk text widget via tcltk
John Fox