[R] seMethod for tkpack and tkgrid

Lars Hougaard Hansen BSA lahh at pubhealth.ku.dk
Thu Jan 30 13:37:06 CET 2003


Hi,

I have a problem, regarding setMethod for "tkpack" and "tkgrid". I define
a new class , with one of the slots being of class "tkwin". I would now
naturel to set a method for packing the "tkwin"-slot; but here I run into
trouble. The code is given below.



## problem regarding "setMethod" for "tkpack" and "tkgrid".

library(methods)
library(tcltk)

# a class, "select", is defined, by

setClass("select",representation(listbox="tkwin", listvariable="tclVar"))

# Defining the method "tclvalue" for an object of class "select", by

setMethod("tclvalue","select",
          function(x)
          tclvalue(x at listvariable)
          )

# is accepted as legal R-code. But, when trying to do the same for 
# "tkpack"  and "tkgrid", R prints an Error.

setMethod("tkpack","select",
          function(x,...)
          tkpack(x at listbox,...)
          )

setMethod("tkgrid","select",
          function(x,...)
          tkgrid(x at listbox,...)
          )

# Error message:
#
# Error in makeGeneric(name, fdef, fdeflt, group = group, valueClass =
# valueClass,  : 
#        No suitable arguments to dispatch methods in this function
  
Can anybody see what the problem might bee?

I am using a Linux-gnu platform and the 1.7.0 version of R. 

Regards,

	Lars Hougaard Hansen


More information about the R-help mailing list