[Rd] Getting width of Tk text widget via tcltk
John Fox
jfox at mcmaster.ca
Mon Feb 28 15:05:03 CET 2005
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
More information about the R-devel
mailing list