[R] R and tcltk, problem to get the value entered

Jouanin Celine celine_jouanin at yahoo.fr
Fri Dec 12 11:02:27 CET 2014


Hi dear R list,
I would like to create a graphical user interface with tcltk.I want to have a window where the user will enter a numeric, this will open a message box with his value. This works, but I don't succeed to get the value x, to use it after in a script in the R console. The x variable doesn't give me the value chosen by the user but returns the initial value "12".How can I do it ? Does exist an another function in tcltk that I need to use ?Thanks for your help
Céline
Here is my code :
library(tcltk2)
tt<-tktoplevel()
tktitle(tt)<-"Select a value"
titre<-tklabel(tt, text="Select a value")
value<-tkentry(tt, width=3, textvariable=tclVar("12"))
ok<-function()
{
    show<-paste("The value is :", tclvalue(tkget(value)))
    tkmessageBox(title="End", message=show, icon="info", type="ok")
    tkdestroy(tt)
}

bouton<-tkbutton(tt, text="OK", command=ok)
tkpack(titre)
tkpack(value,bouton)
x<-tclvalue(tkget(value))
x<-as.numeric(x)
x #this give 12 but I want to have the new value


	[[alternative HTML version deleted]]



More information about the R-help mailing list