[R-gui] TclTk dynamic dropdown list combo box

João Gonçalves joaofgo at gmail.com
Mon Jun 28 12:32:30 CEST 2010


Thank you for taking interest in this problem.
Both solutions proposed worked out very smoothly. I'm certainly going to 
use the gWidgets package more often in my future R projects.

Best regards,
João Gonçalves

jverzani wrote:
> João G.<joaofgo<at>  gmail.com>  writes:
>
>    
>> Thank you! That worked out nicely.
>> I leave here the code used in case it turns out useful for someone else:
>>
>>
>> If you wanted to do this with gWidgetstcltk you could do this:
>>
>> library(gWidgets)
>> options(guiToolkit="tcltk")
>>
>> d<- mtcars ## some data frame
>> w<- gwindow()
>> g<- ggroup(cont=w, horizontal=FALSE)
>> namesCb<- gcombobox(names(d),selected=1, cont=g)
>> valsCb<- gcombobox(c(""), cont=g)
>>
>> updateCb<- function(varname) {
>>    valsCb[]<- d[[varname]]
>>    svalue(valsCb, index=TRUE)<- 1
>> }
>> addHandlerChanged(namesCb, function(h,...) updateCb(svalue(h$obj)))
>> updateCb(svalue(namesCb))
>>
>>
>> --John
>>
>>
>>



More information about the R-SIG-GUI mailing list