Skip to content
Prev 438 / 1236 Next

[R-gui] pure tcl/tk to R-tcltk / labeled frame and image

Dear Peter Dalgaard
Peter Dalgaard wrote:

            
Ok, this is the same "problem" in all of that Megawidgets, isn't it?
If I use your function I get the following error:

....
.Tk.subwin2 <- function (parent, name=evalq(num.subwin <- num.subwin + 1,
                                   parent$env)) {
  ID <- paste(c(parent$ID, name, parent$env), sep = ".")
  win <- .Tk.newwin(ID)
  assign(ID, win, envir = parent$env)
  assign("parent", parent, envir = win$env)
  win
}

.base.labelframe.cs <- .Tk.subwin2(.base.labelframe, "cs")
tclRequire("Img")
t.Logo <- tclVar()
tcl("image", "create", "photo", t.Logo, file = "logo.jpg")
tkpack(tklabel(.base.labelframe.cs, image = t.Logo, bg = "white"),
       fill = "both", expand = TRUE, padx = 5, pady = 5)

Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"), 
class = "tclObj") :
    [tcl] bad window path name ".1.1.1 cs.1 <environment>".


I've seen that you use the same trick in the tabbed notebook example. 
Maybe I have to study that part again.
Yes I know, but the name .base.labelframe.image tells me that image (or 
what ever) is on top of base and labelframe.
I find it just usefull.
Ok, last time I used tcl/tk there was just the tkcmd, I think. I have to 
read the CHANGES/NEWS-files next time again before posting.
Thanks for that correction.

Just to understand what happend I've tried these two examples

## 1
.base <- tktoplevel()
tkwm.title(.base, "Labelframe")
tkpack(.base.labelframe <- tkwidget(.base, "iwidgets::labeledframe",
                                    labelpos = "nw",
                                    labeltext = "Labelframe"),
       fill = "both", expand = TRUE)

cs <- tclVar()
tcl("set", cs, paste("[", .Tk.ID(.base.labelframe), "childsite]"))
t.Logo <- tclVar()
tcl("image", "create", "photo", t.Logo, file = "logo.jpg")
.Tcl(paste("label $cs.l -image ", .Tk.ID(t.Logo)))

[tcl] can't read "cs": no such variable.

This is what you said above I think. The variable "cs" can't be passed 
from R to Tcl and back.

 ## 2    
## what I can't understand is that
.Tk.ID(cs) ## is NULL

If I give it an ID by hand it gives me the following:
...
cs$ID <- ".2.1.cs"
.Tcl(paste("label $",.Tk.ID(cs),".l -image ", .Tk.ID(t.Logo), sep = ""))

bad window path name "$.2.1.cs"

That it does not work is not really surprising, but there is maybe more 
than just set the path name correctly, isn't it?


Thanks for your help. I'll try to get it work, but if you have a hint 
again... would be great.
And thanks for writing that great package.

Thomas