Re: [R] Building tkentry dynamicly
Dear Sean, That was Peter Dalgaard's suggestion, posted a little while ago. It's a much better solution to Alexandre's problem than what I suggested. I'm not sure that it would work for the Rcmdr dialog that I mentioned, but I'll take a look when I have a chance. Regards, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Sean Davis > Sent: Tuesday, March 07, 2006 8:51 AM > To: John Fox; [EMAIL PROTECTED] > Cc: R-Help > Subject: Re: [R] Building tkentry dynamicly > > > > > On 3/7/06 8:29, "John Fox" <[EMAIL PROTECTED]> wrote: > > > Dear Alexandre, > > > > It is possible to do what you want. Take a look, for > example, at the > > dialog box produced by "Statistics -> Contingency tables -> > Enter and > > analyze two-way table" in the Rcmdr package. That dialog > box is able > > to modify itself and to keep variables for an arbitrary number of > > tkentry() boxes. It does this by constructing names for the > variables > > as text strings, and then using assign() and eval() to set and > > retrieve values. (Perhaps there's a more elegant way to do > this.) The > > code for the function enterTable(), which constructs this > dialog, is > > in the file statistics-tables-menu.R in the Rcmdr source package. > > I haven't used tcltk enough to comment in any major way, but > I will ask a question. Couldn't these variables be > maintained as a list? > > Sean > > __ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html __ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Building tkentry dynamicly
On 3/7/06 8:29, "John Fox" <[EMAIL PROTECTED]> wrote: > Dear Alexandre, > > It is possible to do what you want. Take a look, for example, at the dialog > box produced by "Statistics -> Contingency tables -> Enter and analyze > two-way table" in the Rcmdr package. That dialog box is able to modify > itself and to keep variables for an arbitrary number of tkentry() boxes. It > does this by constructing names for the variables as text strings, and then > using assign() and eval() to set and retrieve values. (Perhaps there's a > more elegant way to do this.) The code for the function enterTable(), which > constructs this dialog, is in the file statistics-tables-menu.R in the Rcmdr > source package. I haven't used tcltk enough to comment in any major way, but I will ask a question. Couldn't these variables be maintained as a list? Sean __ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Building tkentry dynamicly
Dear Alexandre, It is possible to do what you want. Take a look, for example, at the dialog box produced by "Statistics -> Contingency tables -> Enter and analyze two-way table" in the Rcmdr package. That dialog box is able to modify itself and to keep variables for an arbitrary number of tkentry() boxes. It does this by constructing names for the variables as text strings, and then using assign() and eval() to set and retrieve values. (Perhaps there's a more elegant way to do this.) The code for the function enterTable(), which constructs this dialog, is in the file statistics-tables-menu.R in the Rcmdr source package. I hope this helps, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: Tuesday, March 07, 2006 7:06 AM > To: [email protected] > Subject: [R] Building tkentry dynamicly > > > > > > > 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 ? > > > Example : > > (Embedded image moved to file: pic14771.jpg) to > (Embedded image moved to file: pic11538.jpg) > > > Regards. > > > > > > > > Alexandre MENICACCI > Bioinformatics - FOURNIER PHARMA > 50, rue de Dijon - 21121 Daix - FRANCE > [EMAIL PROTECTED] > tél : 03.80.44.76.17 __ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Building tkentry dynamicly
[EMAIL PROTECTED] 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
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
