[R] Building tkentry dynamicly
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Tue Mar 7 14:18:04 CET 2006
a.menicacci at fr.fournierpharma.com writes:
> Dear R-users,
>
> I would like to build N "tkentry" compounds in the same window, with
> default text for each. As N is variable I need to construct them in an
> iterative way :
>
>
> library(tcltk)
>
> main<-tktoplevel()
>
> tktitle(main)<-"My Tool"
>
> filenames<-c("toto","tata","titi")
> N<-length(filenames)
>
> for (i in 1: N) {
> text<-tclVar(filenames[i]) # get a filename (string value)
> textField<-tkentry(main,textvariable=text) # build a text field
> tkgrid(textField)
> }
>
> The problem is : How to keep references for each tclVar created, in order
> to acces to the text modifications eventually done for each field ?
Can't you just use lists?
library(tcltk)
main <- tktoplevel()
tktitle(main) <- "My Tool"
filenames <- c("toto", "tata", "titi")
N <- length(filenames)
text <- vector("list", N)
textField <- vector("list", N)
for (i in 1:N) {
text[[i]] <- tclVar(filenames[i]) # get a filename (string value)
textField[[i]] <- tkentry(main,textvariable=text[[i]]) #build a text field
tkgrid(textField[[i]])
}
tclvalue(text[[2]]) <- "tutu"
>
> Example :
>
> (Embedded image moved to file: pic14771.jpg) to
> (Embedded image moved to file: pic11538.jpg)
??!
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list