From r.d.morey at rug.nl  Thu Jul  9 23:57:24 2009
From: r.d.morey at rug.nl (Richard Morey)
Date: Thu, 09 Jul 2009 23:57:24 +0200
Subject: [Rd] Changing text in a tkentry widget
In-Reply-To: <mailman.11.1247133608.27074.r-devel@r-project.org>
References: <mailman.11.1247133608.27074.r-devel@r-project.org>
Message-ID: <4A5667C4.5030002@rug.nl>

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



[Rd] Changing text in a tkentry widget
Richard Morey