i have a gui with a area ggraphics and i would want create a subwindow with the graphic active in the area graphic, but dev.copy and svalue not work
options(guiToolkit = "RGtk2")
win<- gwindow ("window", width=1350,height=680,parent=c(1,1))
buttongraph<-gbutton("Click for enlarge graph",cont=win)
wingraphic<- ggraphics(cont=win)
hist(rnorm(100))
addHandlerChanged(buttongraph,handler=function(h,...){
subwin<- gwindow("subwin")
subwingraph<-ggraphics(cont=subwin)
svalue(wingraphic)
})
or
dev.copy(wingraphic)
The call svalue(wingraphic) <- "filename.png"
tries to produce a graphic using some Gtk calls. It is fragile and if the comment in the file is still accurate, needs the device to be uncovered. Might work for you, but might not.
The ggraphics widget is just a frontend for cairoDevice
which opens a new graphics device. If it was the current device, the call would be dev.copy()
, not dev.copy(wingraphic)
as dev.copy
knows nothing about gWidgets
objects. If you want to get the device for a given ggraphics
object you can grab it with: getToolkitWidget(g)$getData(".devnum")
, but you'll need to load RGtk2
first.
If you just want to make a given ggraphics
instance the current device, you can do so with visible(subwingraph) <- TRUE
.