Hi, I apologize if this is not the proper forum.
I am writing a package to automatically create RGtk GUI's with an arbitrary number of widgets to act as a "control panel" front end for a user-specified plotting or simulation function. The widgets are specified in a list argument to a function and associated with specific parameter values for the user function (FUN), which is called whenever a widget value is modified. For example, a call to: makegui <- function (w=list(x=100, y=200, FUN)) {...} would result in a GUI with slider widgets for parameters "x" and "y". Whenever the sliders are changed, the function FUN is called with the new value of "x" or "y" -- possibly drawing a plot or something else. MY PROBLEM IS THIS: I want to make callbacks for each widget that automatically send new parameter values to the function FUN, but I can't find a way to do this with arbitrary numbers of widgets/parameters and arbitrary names for the widgets. For convenience, I set the parameter names to be the same as the widget names. First I store all initial parameter values in an array, e.g., params <- list(x=100, y=200). widget.names <- c("x", "y") I create each widget with something like: assign(widget.name, gtkWidget(...)) Then I add a callback: get(widget.name)$AddCallback("value-changed", function(w) {callbackFUN(...)}) I want the callbackFUN() function to be able to get the widget's value with something like w$GetValue() and put it into the "params" list, and then finally to send the parameter list to the FUN function. I can't seem to find any way to send a character string of the appropriate arbitrary widget name to the callback function so that I can put the widget value into the parameter list. I've tried setting an attribute of the widget with its associated parameter name when I create the callback, but the attribute seems to disappear when the callback is called. I can get around all this whole problem by simply looping through all of the widgets at once by name: for (i in widget.names) params[[i]] <- get(i)$GetValue() but this approach is inefficient when only one parameter is changed at a time. Am I missing something easy? TIA for any ideas. --Neil Klepeis _______________________________________________ R-SIG-GUI mailing list R-SIG-GUI@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-gui