Skip to content
Prev 153576 / 398500 Next

Open directory within a menu in tcltk

Judith Flores wrote:
This is mainly the effect of an unfortunate choice of variable name. 
Beware the semantics of "<<-". You need to ensure that you have control 
of where the assignment goes to.

It is in general unfortunate to make such assignments to the global 
environment, where they can mask and clobber other objects. I'd consider 
a redesign along the lines of

myGui <- function(....) {
    opendir<-function() {
        dirname<<-tclvalue(tkchooseDirectory())
   }
    dirname <- NA
    tl <- tktoplevel()
   ......
}