Skip to content

[R-gui] Post hoc tweeking of ggenericwidget?

3 messages · j verzani, christiaan pauw

#
Hi Everybody

ggenericwidet in the gWidgets package is really handy - you can get a
basic gui for your function in just about no time. Now I just want to
tweek it a little bit. For example: I want to use gvarbrowser to
select x . Can this type of object be manipulated after the initial
creation or must be all be done when it is created? If

In the process of trying to ascertain this, I tried to see the
structure of the object created by ggenericwidget. This is what
happened:
x=ggenericwidget("boxplot.default", container=TRUE)  # example from
the help file
str(x)
      # I am trying to use str() to see the structure of x so that I
can figure out how to manipulate certain aspect

Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function ".length", for
signature "gGenericWidgetANY", "guiWidgetsToolkitRGtk2"

Is this a problem in my system or is the object not accesable to str() ?

Thanks in advance
Christiaan
R version 2.14.0 (2011-10-31)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets
methods   base

other attached packages:
[1] cjp_1.1              Hmisc_3.9-0          survival_2.36-10
RGtk2_2.20.19        gWidgetsRGtk2_0.0-77 traitr_0.12
[7] gWidgets_0.0-47      proto_0.3-9.2        digest_0.5.1

loaded via a namespace (and not attached):
[1] cluster_1.14.1 grid_2.14.0    lattice_0.20-0 tools_2.14.0
#
christiaan pauw <cjpauw <at> gmail.com> writes:
The idea behind this widget is there are two steps: one to create
a list specifying how to layout the dialog and the other to make the 
dialog. If you want to modify the object, you modify the list, not the 
dialog. The list can be obtained two ways. See either:

cat(gWidgets:::autogenerategeneric(mean))

or

svalue(ggenericwidget(mean))


The whole thing is pretty limited and you'll bump into its walls
if you try too much, but it can make basic dialogs very simple.
The gformlayout adds a bit more functionality for mapping a list 
into a dialog, but has nothing to autogenerate the list.

--John
#
Thanks John

I have tried another approach after reading your advice. I followed
the example in the traitr vignette and included ggenericwidget inside
a traitr dialog together with a gvarbrowser object. Now you can drop
objects from the wordkspace browser (because in practice I always
froget or misspel something). All that is needed to implement this for
another function is varying the second last line.

regards
Christiaan

require(traitr)
options("guiToolkit"="RGtk2")

tt=stats:::t.test.default

d.dlg <- aDialog(items=list(),
title="generic dialog",
help_string="You're on your own here. Good night and good luck",
buttons=NULL
)

g=aGroup(attr=list(size=c(500,500)))
g2=aGroup()

g.view <- aGroup(
aContainer(
aFrame(aContainer(g2),label="Write var name or drop var for x")
),
aFrame(aContainer(g),label="Workspace Browser")
,horizontal=TRUE)
	
d.dlg$make_gui(gui_layout=g.view,visible=FALSE)

varbrowser <- gvarbrowser(cont=g$container)
tt.w <- ggenericwidget(tt,cont=g2$container)

d.dlg$visible(TRUE)
On 2 December 2011 22:55, j verzani <jverzani at gmail.com> wrote: