Hi, The tkfilefind demo in the tcltk package doesn't seem to work for me in Windows2000. The demo script uses tkfilefind(".") which doesn't display the parent directory so you can't browse around the whole drive. Using tkfilefind() (which uses the default path getwd()) doesn't seem to work for me at all. I also tried tkfilefind("/") which worked fine but then using> a<-tkfilefind("/") > a[1] "//jm2.null.mc.img"> library(AnalyzeFMRI) > f.analyze.file.summary(a)causes R to crash i.e. using "//jm2.null.mc.img" as a path to a file doesn't seem to work. I found a way round it using path<-getwd() if(.Platform$OS.type == "windows") { path<-paste(substring(getwd(),1,2),Platform()$file.sep,sep="") } tkfilefind(path) but this only allows you to access files on the drive of the working directory. I also found a problem selecting a file when the path has spaces. IIt seems to return a vector of characters> tkfilefind("C:/")[1] "C:/Program/Files" "/R/rw1031/FAQ" I was wondering if there was an easier way around these problems? I find the tkfilefind function very useful when writing small GUI's that read/write data from files. Cheers, Jonathan -- Jonathan L. Marchini, (home) jonathan.marchini at balliol.ox.ac.uk Department of Statistics, (work) marchini at stats.ox.ac.uk University of Oxford, http://www.stats.ox.ac.uk/~marchini 1 South Parks Road, Tel: +44 1865 272593 (work) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Jonathan Marchini wrote:> > Hi, > > The tkfilefind demo in the tcltk package doesn't seem to work for me in > Windows2000. > > The demo script uses tkfilefind(".") which doesn't display the parent > directory so you can't browse around the whole drive.Right, it uses the working directory ... and works fine on WinNT4.> Using tkfilefind() (which uses the default path getwd()) doesn't seem to > work for me at all.Which is the same here ... What you want is: setwd("c:/") demo(tkfilefind)> I also tried tkfilefind("/") which worked fine but then using > > > a<-tkfilefind("/") > > a > [1] "//jm2.null.mc.img" > > library(AnalyzeFMRI) > > f.analyze.file.summary(a) > causes R to crash i.e. using "//jm2.null.mc.img" as a path to a file > doesn't seem to work.That's a bug in package AnalyzeFMRI, which doesn't check the existance of the file. file.exists(a) # should give FALSE !!! What you want is: tkfilefind("c:/")> I found a way round it using > > path<-getwd() > if(.Platform$OS.type == "windows") { > path<-paste(substring(getwd(),1,2),Platform()$file.sep,sep="") > } > > tkfilefind(path) > > but this only allows you to access files on the drive of the working > directory.What about tkfilefind("c:/"), tkfilefind("d:/"), tkfilefind("e:/"), ... ???> I also found a problem selecting a file when the path has spaces. IIt > seems to return a vector of characters > > > tkfilefind("C:/") > [1] "C:/Program/Files" "/R/rw1031/FAQ"That's hard to fix if you also want to be able to make multiple selections.> I was wondering if there was an easier way around these problems? I find > the tkfilefind function very useful when writing small GUI's that > read/write data from files.It is much easier to use file.choose() on Windows!!! Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Jonathan Marchini <marchini at stats.ox.ac.uk> writes:> Hi, > > The tkfilefind demo in the tcltk package doesn't seem to work for me in > Windows2000. > > The demo script uses tkfilefind(".") which doesn't display the parent > directory so you can't browse around the whole drive. > > Using tkfilefind() (which uses the default path getwd()) doesn't seem to > work for me at all. > > I also tried tkfilefind("/") which worked fine but then using > > > a<-tkfilefind("/") > > a > [1] "//jm2.null.mc.img" > > library(AnalyzeFMRI) > > f.analyze.file.summary(a) > > causes R to crash i.e. using "//jm2.null.mc.img" as a path to a file > doesn't seem to work. > > I found a way round it using > > path<-getwd() > if(.Platform$OS.type == "windows") { > path<-paste(substring(getwd(),1,2),Platform()$file.sep,sep="") > } > > tkfilefind(path) > > but this only allows you to access files on the drive of the working > directory. > > I also found a problem selecting a file when the path has spaces. IIt > seems to return a vector of characters > > > tkfilefind("C:/") > [1] "C:/Program/Files" "/R/rw1031/FAQ" > > I was wondering if there was an easier way around these problems? I find > the tkfilefind function very useful when writing small GUI's that > read/write data from files.Hmmm.... It is after all just a demo, intending to show how you might communicate with a fairly complex Tcl module. It could well be the case that the "hierarchy_dir" widget on which it builds has shortcomings and you could go looking for another file selector dialog. Or maybe you could take a closer look at the function and modify it to suit your needs. However, after poking around a bit, I'm 95% confident that what you really want is tkcmd("tk_getOpenFile")... -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._