I assume that what is wanted is that "Anonymous" should change to "changed name" when the "Change" button is pressed.
In that case enter this and then press the Change button at which point "Anonymous" should change to "changed name". library(tcltk) tt <- tktoplevel() Name <- tclVar("Anonymous") entry.Name <-tkentry(tt, width = "20", textvariable = Name) tkgrid(entry.Name) OnChange <- function() { tclvalue(Name) <- "changed name" } Change.but <-tkbutton(tt,text=" Change ",command = OnChange) tkgrid(Change.but) tkfocus(tt) On Thu, Jul 9, 2009 at 5:57 PM, Richard Morey<r.d.mo...@rug.nl> wrote: > I searched the web and the list archives for a solution to this, but didn't > see anything, so here goes. I'm new to tcltk. I'm trying to change the > contents of a tkentry widget when a button is pressed. Once I get that > working, the widget will be read only to the user. Here is some toy code: > > ############### > require(tcltk) > thisEnv=environment() > tt<-tktoplevel() > Name <- tclVar("Anonymous") > entry.Name <-tkentry(tt,width="20",textvariable=Name) > tkgrid(entry.Name) > OnChange <- function() > { > assign("Name",tclVar("changed name"),thisEnv) > } > Change.but <-tkbutton(tt,text=" Change ",command=OnChange) > tkgrid(Change.but) > tkfocus(tt) > ################## > (much of this is taken from > http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/editboxes.html) > > Now, I thought the whole point of the textvariable argument was to change > the content of the tkentry widget. But, as you can see by running this code, > changing the Name variable using assign does not change the content of the > widget. > > Is there a function to update the content? tkinsert didn't seem to work when > I tried it. > > Thanks, > Richard Morey > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel