Re: [R] tcltk crashing R after the (ab)use of tkwait

From: Mike Meredith <mmeredith_at_wcs.org>
Date: Sat, 26 May 2007 18:01:04 -0700 (PDT)

>> library(tcltk)
>> tt <- tktoplevel()
>> done <- tclVar(0)
>> but <- tkbutton(tt, text="OK", command=function() tclvalue(done) <- 1)
>> tkpack(but)
>> tkwait.variable(done)
>>
>> works as fine as long as I click the OK. However, if I close
>> the window (by clicking in the X), R enters into an infinite loop
>> and there's no way of returning except by closing the R window.

I have the same pbm with R 1.5.0 on Window XP Home SP2.

I think it's doing what it's supposed to, ie. waiting for done==1, just that this never happens.

I've stopped using tkwait.variable for just this reason, and use tkwait.window(tt). You have to be careful to recover the variables you need before closing the window, so the function attached to the 'OK' button should take care of that before calling tkdestroy. (See http://www.nabble.com/Dropdown-boxes-in-tcltk-and-R-tf3751327.html#a10603161)

Variables can be created in .GlobalEnv with <<- which will be availble after the function exits. See also how Greg Snow uses a purpose-built environment in his 'TeachingDemos' package.

Mike



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-- 
View this message in context: http://www.nabble.com/tcltk-crashing-R-after-the-%28ab%29use-of-tkwait-tf3487962.html#a10821463
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 27 May 2007 - 01:07:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 27 May 2007 - 03:31:39 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.