To elaborate on my comment, here is an example using both an environment and <<-
require(gWidgets2)
options(guiToolkit="RGtk2")
input <- NULL # global
e <- new.env() # environment
win = gwindow("Stage 1")
g = ggroup(horizontal=FALSE,cont=win)
gbutton("Input folder",cont=g,handler=function(...) {
value <- gfile(type="selectdir")
gmessage(paste0("Input directory set to ",value))
## assign via <<-
input <<- value
## assign to an environment
e$input <- value
})
gbutton("What is stored?", cont=g, handler=function(...) {
print(sprintf("The global variable has %s", input))
print(sprintf("The environment stores %s", e$input))
})