[R] Tcl/Tk window lingering too long

David Firth david.firth at nuffield.oxford.ac.uk
Fri Feb 22 19:54:30 CET 2002


Many thanks to Brian and Peter for their swift and helpful responses.

I tried Peter's suggestion (I think), as in

test<-function(){
	base<-tktoplevel()
		ok.but<-tkbutton(base,text="OK",
		         command=function(){
		             tkdestroy(base)
		             })
		tkpack(ok.but)
		tkwait.window(base)
	x<-rnorm(400000)
         print("finished")}

but that version seems to have the same problem as before.

David

>David Firth <david.firth at nuffield.oxford.ac.uk> writes:
>
>>  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.
>
>Hmm... I wonder if we're not missing a way to force a run of the Tcl
>event loop, but the canonical way would be (I think) to make the
>button callback destroy the window and use tkwait.window(base) rather
>than tkwait.variable().
>
>--
>    O__  ---- Peter Dalgaard             Blegdamsvej 3 
>   c/ /'_ --- Dept. of Biostatistics     2200 Cph. N  
>  (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
>~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
>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
>_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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