Hi, All: I created several plots in R and associated them with tabbed notebook widget (created from the example on the R tcl/tk page http://www.sciviews.org/_rgui). The plot itself is created by tkrplot. What I'd llike to do is to save the current plot associated with the active tab. I searched online and couldn't get it done. Your help is well appreciated!
I am attaching this example code from that website. Basically, when I click tab "B", I want to save the corresponding plot. I used "CopytoClipboard" button. But it always copies the last plot, ie. tab Z's plot. I guess I need handle the imglist as a list, but it didn't allow me to do. ####### modified example code ############ library(tcltk) library(tkrplot) tclRequire("Iwidgets") tt <- tktoplevel() tkpack(tn <- tkwidget(tt, "iwidgets::tabnotebook")) tkconfigure(tn, # prettyfication taken from incrtcl tabpos="n", width=1050, height=850, angle=0, bevelamount=2, gap=2, margin=2, tabborders=0, tabbackground="white", background="lightgray", backdrop="lightgray") nm <- LETTERS[1:26] for (t in 1:length(nm)) { tbn <- tclvalue(tkadd(tn, label=nm[t])) tkpack(tbw <- .Tk.newwin(tbn)) tkpack(fr <- tkframe(tbw)) tkpack(lb <- tklabel(fr, text=paste("This is tab", nm[t]))) ID <- paste(tn$ID, evalq(num.subwin<-num.subwin+1, tn$env), sep=".") win <- .Tk.newwin(ID) assign(ID, tbw, envir = tn$env) assign("parent", tn, envir = tbw$env) imglist <- tkrplot(fr,function() { X <- t + (1:20) plot(X)}, hscale= 1.5, vscale= 1.5) CopyToClip <- function() { tkrreplot(imglist) } copy.but <- tkbutton(tbw,text=paste("Copy to Clipboard", nm[t]),command=CopyToClip) tkpack(imglist) tkpack(copy.but) #list(tbw,fr,lb) # return all three in case you need them later } tkbind(tt, "<Destroy>", function() tkdestroy(tn)) tkselect(tn, 0) ____________________________________________________________________________________ Cheap talk? _______________________________________________ R-SIG-GUI mailing list R-SIG-GUI@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-gui