Re: [Rd] tcltk resizing when using tkgrid for layout

From: Alex Bokov <>
Date: Wed, 21 Jul 2010 10:50:39 -0500

On 07/21/2010 09:36 AM, Alex Bokov wrote:
> I've been able to figure out on my own how to do what I need in the
> largely undocumented tcltk package, but I've finally hit a wall. I
> can't even think of any sufficiently specific search terms to use for
> this.
Oops. Murphy's Law-- the answer only comes to you after you already send off an email to the experts. Sorry to bother you, I figured it out already. Here's how to make the code example I posted earlier...

> require(tcltk)
> tt<- tktoplevel()
> xscr<- tkscrollbar(tt, repeatinterval=5,orient="horizontal",
> command=function(...)tkxview(txt,...))
> yscr<- tkscrollbar(tt, repeatinterval=5,
> command=function(...)tkyview(txt,...))
> txt<- tktext(tt,bg="white",font="courier",
> xscrollcommand=function(...)tkset(xscr,...),yscrollcommand=function(...)tkset(yscr,...),
> wrap="none")
> tkgrid(txt,yscr)
> tkgrid(xscr)
> tkgrid.configure(yscr,sticky="ns")
> tkgrid.configure(xscr,sticky="ew")
> for (i in (1:100)) tkinsert(txt,"end",paste(i,"^ 2 =",i*i,", "))
> tkconfigure(txt, state="disabled")
> tkfocus(txt)
...resize dynamically. All I had to do was add the following lines to the end of it:


I had been so close before, I just didn't realize that if you have a complicated frame structure enclosing the widget, then the weight needs to be set on every enclosing frame, not just the widget itself. The hard part is figuring out which row and column a column-spanning widget really belongs to-- so far it seems to belong to the left-most and top-most one.

Anyway, thanks to anybody who was going to answer this, hopefully I'm sending this soon enough to save you the effort of composing a reply. Have a great day!

        [[alternative HTML version deleted]] mailing list Received on Wed 21 Jul 2010 - 15:56:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 21 Jul 2010 - 16:10:18 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive