[R] autofill for a tkentry field

From: Adrian Dragulescu <adrian_d_at_eskimo.com>
Date: Mon 01 Jan 2007 - 16:54:26 GMT

Hello all,

I'm experimenting with tlk/tk and I find it very useful. I would like to have the text of a tkentry be automatically filled when the user starts typing, according to a predetermined list. I've found a solution on the tcl wiki pages, but I don't quite know how to translate it in R... Here is the tcl code: http://wiki.tcl.tk/13267

And here is my code that does not work.
 autofill <- function(){

    cat("I was here!")
    entry <- tclvalue(f1)
    ind <- grep(entry, fruitList)
    if (length(ind)>0){f1 <- tclVar(fruitList[ind[1]])}    }

  fruitList <<- c("Apple", "Banana", "Peach", "Pear", "Plum", "Mango")   tkdestroy(tt)

  tt  <- tktoplevel()
  pw  <- tkframe(tt)
  ppw <- tk2labelframe(pw, text="Fruits:")
  f1  <<- tclVar("")
  entry1.f <- tkentry(ppw, width=30, textvariable=f1, validate="key",
                      validatecommand=autofill)
  tkgrid(entry1.f)

  tkgrid(ppw)
  tkgrid(pw)

I don't know how to pass arguments to the autofill function, so I can manipulate the textvariable. Any help is much appreciated. If we get a working solution, maybe we should add this example to http://www.sciviews.org/_rgui/tcltk/index.html.

Thank you,
Adrian



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. Received on Tue Jan 02 03:58:52 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 01 Jan 2007 - 17:30:29 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.