[R] tktext-window smaller than text

Anne Skoeries studentin at anne-skoeries.de
Mon Oct 12 14:05:56 CEST 2009

Hi there,

I need to build up a  tktext-widget that contains a longer text than  
the tktext-widget actually is. So what I mean is, that the tktext  
window is of width=100 and the text in it has a length greater 100.  
But I don't want the window to just wrap the line, but to belong to  
scrollbar that is able to scroll to the end of the text.

tt <- tktoplevel()
txt <- tktext(tt, width=100, height=30)

scrergVert <- tkscrollbar(tt, orient = "vertical", repeatinterval = 1,  
command = function(...) tkyview(txt, ...))
tkconfigure(txt, yscrollcommand = function(...) tkset(scrergVert, ...))
scrergHor <- tkscrollbar(tt, orient = "horizontal", repeatinterval =  
1, command = function(...) tkxview(txt, ...))
tkconfigure(txt, xscrollcommand = function(...) tkset(scrergHor, ...))

tkgrid(txt, column=0, row=0, sticky="nwse")
tkgrid(scrergVert, column=1, row=0, sticky="ns")
tkgrid(scrergHor, column=0, row=1, sticky="we")

tkinsert(txt, "0.0", paste(capture.output(resultKmean), collapse="\n"))

Trying the upper code would wrap the lines that are contain more than  
100 characters. How can I keep the size of the window, but make the  
text scrollable?

Thanks in advance,
Anne Skoeries

More information about the R-help mailing list