Dear Yvonnick and Gabor,

I use a different implementation for each, but this gave me some place to
look. For gradio for gWidgetsRGtk2 I decoupled the handler call from the
widget so replacing radio buttons was easier. The R5 class I made, for some
reason, doesn't play nicely with this proto object. Here is a simplified
example:

library(proto)
a <- setRefClass("Test",
                 fields=list(
                   o = "function"
                   ),
                 methods=list(
                   initialize=function(o) {
                     o <<- o
                   }))

example = proto(
 create = function(.) {
   a$new(.$onChoice)
 },
 onChoice = function(.,h,...) {
   print("hi")
 }
)


When setting the "o" property R tries coercion to a function and you get
this error.

Gabor, any thoughts? This deep dark magic is one of your many specialities.

--John

On Fri, May 13, 2011 at 7:30 AM, Gabor Grothendieck <ggrothendi...@gmail.com
> wrote:

> On Fri, May 13, 2011 at 2:37 AM, Yvonnick Noel <yvonnick.n...@uhb.fr>
> wrote:
> > Hello John,
> >
> > Hope you are doing well.
> >
> > I note the following problem with the last version of gWidgetsRGtk2.
> > Defining a gradio handler as a function embedded in a proto class leads
> to
> > an error :
> >
> > library(proto)
> > library(gWidgetsRGtk2)
> >
> > example = proto(
> >  create = function(.) {
> >
> >    .$window = gwindow(visible=FALSE)
> >    .$choice = gradio(1:3,cont=.$window,handler=.$onChoice)
> >    visible(.$window)=TRUE
> >  },
> >  onChoice = function(.,h,...) {
> >    cat("You clicked",svalue(.$choice),"\n")
> >  },
> >  window = NULL,
> >  choice = NULL
> > )
> >
> > example$create()
> >
> > Error in as(value, "function") :
> >  internal problem in as(): "instantiatedProtoMethod" is(object,
> "function")
> > is TRUE, but the metadata asserts that the 'is' relation is FALSE
> >
> > Note that is works if I define the onChoice function outside the proto
> > object, and it also works if a replace the gradio by a gdroplist, so it
> > seems specific to gradio.
> >
> > Thank you in advance for your help.
> >
> > Best wishes,
> >
> > Yvonnick Noel
> > University of Brittany, Rennes
> > France
> >
>
> On my system it works even with gradio if gWidgetsRGtk2 is replaced by
> gWidgetstcltk.
>
> > packageVersion("gWidgets")
> [1] ‘0.0.44’
> > packageVersion("gWidgetstcltk")
> [1] ‘0.0.43’
> > packageVersion("proto")
> [1] ‘0.3.9.2’
> > R.version.string
> [1] "R version 2.13.0 Patched (2011-04-25 r55638)"
> > win.version()
> [1] "Windows Vista (build 6002) Service Pack 2"
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>



-- 
John Verzani
Chair, Department of Mathematics
College of Staten Island, CUNY
verz...@math.csi.cuny.edu

        [[alternative HTML version deleted]]

_______________________________________________
R-SIG-GUI mailing list
R-SIG-GUI@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-gui

Reply via email to