r - How to wait for user to input values in combo box in gWidgets2RGtk2? -


i want user input , source file based on input . r code executes without letting user select , executes next statement.

library(gwidgets2rgtk2)  w <- gwindow(title="hello world",visible=true) g = ggroup(horizontal = false, cont=w) glabel("please select favorite subject", cont=g) modeltype <- c("","science","math") op1 <- gcombobox(modeltype, cont=g)  if (svalue(op1)=="math"){     source("rscript1") }else if (svalue(op1)=="science"){     source("rscript2") }else{     source("rscript3") } 

now before close window or select option drop down list, automatically takes "" value , goes else statement , runs rscript3 . how can pause execution till input user. thanks.

the handler function called when item selected in combo box. place put actions:

addhandlerchanged(op1, handler=function(...){     if (svalue(op1)=="math"){       source("rscript1")     }else if (svalue(op1)=="science"){       source("rscript2")     }else{       source("rscript3")     } }) 

Comments