Skip to content
Prev 749 / 1236 Next

[R-gui] tcltk problem using "in"

Replying to myself, though not sure that the threading will be  
preserved (long story short: I use gmail+pop, and as a consequence  
don't see my posts to the list, so I am responding to my sent message).

The problem is "explained" by the following code:

tktest <- function(parent) {
   fr <- tkframe(parent, borderwidth=2, relief="raised")      # Line 1
   l1 <- tklabel(parent, text="b")                           # Line 2
   l2 <- tklabel(fr,text="a")
   tkgrid(l1,l2, `in`=fr)
   fr
}

tt <- tktoplevel()
tf1 <- tktest(tt)
tkgrid(tf1)

The above code, as it stands, produces a nice frame with two letters,  
a and b, in it.
Now, if we interchange the lines I called Line 1 and Line 2 above,  
then in the resulting frame b doesn't show up any more, though there  
is space reserved for it.

In other words,  a widget cannot be inserted into a frame that was  
created after the widget came to existence (in which case we have to  
use the "in" argument). A quick check with code directly in Tcl/Tk  
seems to indicate that this is actually a limitation of Tcl/Tk  
(sounds to me a bit silly to have such limitation though).

Unfortunately, this makes what I was intending to do a lot more  
difficult. I was hoping to create "tkcbind" and "tkrbind" commands to  
allow one to build the GUI from the ground up. It sounds like I would  
need, at the very least, to specify beforehand the overall frame  
structure, and thus move top-to-bottom instead.

Is this problem documented anywhere?

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College
On Dec 21, 2007, at 7:38 PM, Charilaos Skiadas wrote: