0

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)
narteaga
  • 147
  • 2
  • 12

1 Answers1

0

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.

jverzani
  • 5,600
  • 2
  • 21
  • 17
  • i want to enlarge the active graph in `wingraph` in a subwindow `subwingraph` but i dont want to utilize `subwingraph <- ggraphics(cont=subwin) ; hist(rnorm(100))` because the idea is update the graph in `wingraphic` and the code used, it can to update this graph on `subwingraph` without changing the code – narteaga Jul 09 '13 at 13:50
  • You might want to write the current graphic to an image file and display through `gimage` in that case. – jverzani Jul 09 '13 at 15:19