Hello,

    I am trying to setup a menu to open files and directories. I have the 
following code:




opendir<-function() {
  dirname<<-tclvalue(tkchooseDirectory())
}

openfile<-function() {
  filename<<-tclvalue(tkgetOpenFile())
}

require(tcltk)
t1<-tktoplevel()
topMenu<-tkmenu(t1)
tkconfigure(t1,menu=topMenu)

plotMenu<-tkmenu(topMenu, tearoff=FALSE)

tkadd(plotMenu,"command",label="Open file", command=openfile)
tkadd(plotMenu, "command",label="Select directory",command=opendir)
tkadd(plotMenu,"command",label="Quit", command=function() tkdestroy(t1))
tkadd(topMenu, "cascade", label="Menu",menu=plotMenu) 

tkfocus(t1)

  I can extract a file, but not a directory, I obtain the following error 
message:

Error in function ():
cannot change value of locked binding for 'dirname'.

  I would appreciate very much any help or explanation on this.

As always, thank you,

Judith

______________________________________________
R-help@r-project.org 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.

Reply via email to