[R] Tcl/Tk window lingering too long
David Firth
david.firth at nuffield.oxford.ac.uk
Fri Feb 22 19:12:14 CET 2002
I want to set up a simple Tk dialog interface to a function in R,
such that when the "OK" button is pressed, the dialog window is
destroyed and then R does its work on the data/parameters/whatever
that were entered in the dialog. The function "test" below is a
simple prototype.
My problem: upon running test() and hitting "OK", R does its work
(ie, computes rnorm(400000) in the silly example below), and only
*after* that does the dialog window disappear. Is there some way to
make sure that the window disappears immediately after hitting "OK"?
I am using R and Tcl/Tk under Darwin/X11. Exact version information
below. I have made similar dialogs before with a Windows version and
my recollection is that I didn't have this problem -- is it perhaps a
system-dependent thing?
Any hints would be welcomed.
Thanks,
David
test<-function(){
require(tcltk)
base<-tktoplevel()
done<-tclVar(0)
ok.but<-tkbutton(base,text="OK",
command=function(){
tclvalue(done)<-3
})
tkpack(ok.but)
tkwait.variable(as.character(done))
tkdestroy(base)
x<-rnorm(400000)
print("finished")}
> version
_
platform powerpc-apple-darwin5.3
arch powerpc
os darwin5.3
system powerpc, darwin5.3
status
major 1
minor 4.1
year 2002
month 01
day 30
language R
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list