[R] tcltk and locator interaction

Denham Robert Robert.Denham at nrm.qld.gov.au
Fri Jun 7 01:49:06 CEST 2002

I was trying to write a small routine using the tcltk library which
allows a little bit of interaction with a plot.  Basically, using the
function locator(1), a user could click on an area of a graph which
would cause a little tcltk window to pop up.  When they have finished
with the window, they click on a tcltk button, the window disappears,
allowing the user to select another point on the graph and repeat the

This sort of works, but I can't get the tcltk window to disappear in
between mouse clicks, so the user clicks, the window pops up, they press
ok, but the window remains until _after_ a new point has been selected.
Here is an example:

for(i in 1:3) {
# I want the window from tq to disappear after pressing ok
# then wait until after a point has been selected before
# reappearing.  But how?


"tq" <-
  base <- tktoplevel()
  done <- tclVar(0)
  q.but <- tkbutton(base,text="Quit",
                    command=function()tclvalue(done) <- 1)
  tkbind(base, "<Destroy>", function()tclvalue(done) <- 2)
  if(tclvalue(done)=="2") stop("aborted")

I am working on Solaris using R 1.5.0.

Robert Denham

The information in this e-mail together with any attachments is
intended only for the person or entity to which it is addressed
and may contain confidential and/or privileged material.

Any form of review, disclosure, modification, distribution
and/or publication of this e-mail message is prohibited.  

If you have received this message in error, you are asked to
inform the sender as quickly as possible and delete this message
and any copies of this message from your computer and/or your
computer system network.  

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