[R-gui] Automatic Widget Creation and Callbacks in RGtk

Michael Lawrence lawremi at iastate.edu
Mon Apr 24 13:00:19 CEST 2006



> 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.
>
>   
How about passing the parameter name as the "user data" to the callback.
Like:

gSignalConnect(widget, "value-changed", fun, parameter_name)

Then that string is passed as the last parameter to 'fun'.
Then you can update your global data structure.

Note: the code above is for RGtk2, but it looks like you're using the 
old RGtk for GTK+ 1.2.
Why not upgrade? http://www.ggobi.org/rgtk2

You could also use gObjectSetData() like widget$setData("param-name", 
param_name)
Then widget$getData("param-name") to get it back out.
> 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.
>
>   
Are you sure this is that inefficient? How many widgets do you have per 
GUI? This would be the simplest way to do it.

Michael
> _______________________________________________
> R-SIG-GUI mailing list
> R-SIG-GUI at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-gui
>



More information about the R-SIG-GUI mailing list