1

If there is a way to embed in gWidgets objects from other packages. For example from the package utils.

options(guiToolkit = "RGtk2")
library(RGtk2)
library(gWidgets)
library(gWidgetsRGtk2)

library(utils)

w <- gwindow() # gwindow {gWidgets}
e <- edit(InsectSprays) # edit.data.frame {utils} 
Artem
  • 3,304
  • 3
  • 18
  • 41
Apostolos Polymeros
  • 823
  • 1
  • 8
  • 19
  • `edit.data.frame` returns the edited data frame. I guess you mean "can you embed R's dataviewer into a gWidget window". In which case the answer is probably not. – Richie Cotton Jan 23 '12 at 18:07
  • You are right. The answer is probably not. My question comes from the idea a widget to incorporate objects from other packages. Anyway, TNX – Apostolos Polymeros Jan 23 '12 at 18:13
  • There's no reason why you can't mix and match gWidgets GUIs with things created elsewhere: you just can't have them in the same window. So you can have a gWidgets button that clicking opens the R dataviewer window, or whatever. – Richie Cotton Jan 23 '12 at 18:24

1 Answers1

0

It is not possible as gWidgets supports only objects of the certain class like gButton, gWindow etc. gWidgets does not contain documented functions to import \ embed external library \ package GUI objects. E.g.

options(guiToolkit = "RGtk2")
library(RGtk2)
library(gWidgets)
library(gWidgetsRGtk2)

library(utils)

win <- gwindow("Window example",
               handler=function(h,...) {
                 print("See ya")
               })
but <- gbutton("cancel", container=win,
        handler = function(h,...) dispose(win))

str(but)  # gButton class object structure

# Formal class 'gButton' [package "gWidgets"] with 2 slots
# ..@ toolkit:Formal class 'guiWidgetsToolkitRGtk2' [package "gWidgets"] with 1 slot
# .. .. ..@ toolkit: chr  ...
# ..@ widget :Warning in str.default(obj, ...) :
#   'str.default': 'le' -- это NA, так что беру как 0
# Formal class 'gButtonRGtk' [package "gWidgetsRGtk2"] with 3 slots
# .. .. ..@ block  :Classes 'GtkAlignment', 'GtkBin', 'GtkContainer', 'GtkWidget', 'GtkObject', 'GInitiallyUnowned', 'GObject', 'RGtkObject' <externalptr> 
#   .. .. .. ..- attr(*, "interfaces")= chr [1:2]  ...
# .. .. ..@ widget :Classes 'GtkButton', 'GtkBin', 'GtkContainer', 'GtkWidget', 'GtkObject', 'GInitiallyUnowned', 'GObject', 'RGtkObject' <externalptr> 
#   .. .. .. ..- attr(*, "interfaces")= chr [1:3]  ...
# .. .. ..@ toolkit:Formal class 'guiWidgetsToolkitRGtk2' [package "gWidgets"] with 1 slot
# .. .. .. .. ..@ toolkit: chr  ...

moreover after execution of the code the code returns control to the R programming environement.

In contrast utils::edit function returns the data.frame object and suspend R execution environement.

Based on the comment jverzani, the new version of the package gWidgets2 allows to get access to the underlying widgets if you want to integrate into other GUIs. Using gWidgets2's getToolkitWidget method it is possible to attach underlying GUI items into a layout, the add method should work.

Artem
  • 3,304
  • 3
  • 18
  • 41
  • You can get access to the underlying widgets if you want to integrate into other GUIs. Using gWidgets2, makes this easier, as there is a `getToolkitWidget` method. If you want to attache underlying GUI items into a layout, the `add` method should work. – jverzani Dec 31 '19 at 21:28
  • Thanks, I'll added to the body of the answer. – Artem Jan 10 '20 at 05:19