[R] GUI checkbox linked to entry

Peter Wolf s-plus at wiwi.uni-bielefeld.de
Thu Apr 29 18:52:56 CEST 2004


Julien Glenat wrote:

>Hi , i am using R 1.8 and tcltk library in order to make a GUI and i would 
>like to know if it is possible to link a check box to one or more entry 
>dynamically (and eventually other widgets) .
>( in concrete terms : if the check box is ticked the entry is avaible for 
>input and unavaible when not ticked)
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>
Are you looking for something like this?

require(tcltk)
cbValue <- tclVar("0"); info<-tclVar("initial text")
top <- tktoplevel()
cb  <- tkcheckbutton(top,variable=cbValue,text="write or not")
en  <- tkentry      (top,textvariable=info,state="disabled")
exit<- tkbutton     (top, text="exit", command=function() tkdestroy(top))
tkpack(cb,en,exit)

set.entry.state<-function(){
    on.off<-tclvalue(cbValue)
    if(on.off=="1") tkconfigure(en, state="normal")
    if(on.off=="0") tkconfigure(en, state="disabled")
    print(on.off)
}
tkbind(top,"<1>",set.entry.state)

Do you know http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples?

Peter Wolf




More information about the R-help mailing list