[R-gui] Automatic Widget Creation and Callbacks in RGtk
Neil E. Klepeis
nklepeis at sbcglobal.net
Mon Apr 24 22:50:28 CEST 2006
Thanks Michael,
I'd switch to RGtk2 except I recall the dependency is Gtk 2.8.0.
Even though the Gtk 1.2 API states that gtkObjectSetData/GetData are
available, I can't get them to work with Scale widgets in RGtk, e.g.
with w$SetData("key", value). Are these only available with RGtk2?
Anyway, I guess I'll stick with looping over all the widgets until I can
upgrade to RGtk2. You're right that it probably won't be too bad.
Thanks for RGtk2!
Neil
Michael Lawrence wrote:
>
>
>> 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
More information about the R-SIG-GUI
mailing list