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

2007-05-26 Thread Mike Meredith

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


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

2007-03-29 Thread Alberto Monteiro
Running this:

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.

Why? What am I doing wrong?

Alberto Monteiro

__
R-help@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.


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

2007-03-29 Thread Dieter Menne
Alberto Monteiro albmont at centroin.com.br writes:

 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.
 
Works for me with R-2.4.1 on Windows 2000. So better tell us about the details
of your operating system.

Dieter

__
R-help@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.


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

2007-03-29 Thread Alberto Monteiro
Dieter Menne wrote:
 
 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.
 
 Works for me with R-2.4.1 on Windows 2000. So better tell us about 
 the details of your operating system.

R 2.4.1 on Windows XP. Should they work differently?

Alberto Monteiro

__
R-help@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.