r - (tcltk) File browser path display -
i need show file path in in window gui built tcltk after file has been selected user.
library(tcltk) library(tcltk2) #create main window window <- tktoplevel() #creates tab window$env$nb <- tk2notebook(window, tabs = ("raw data")) tkpack(window$env$nb, fill = "both", expand = true) #renames tab window$env$rawtab<-tk2notetab(window$env$nb, "raw data") #function allows user select file getdata <- function(){ name <- tclvalue(tkgetopenfile( filetypes= "{ {csv files} {.csv} } { {all files} * }")) if (name == "") return(data.frame()) sc_data <- read.table(name, header=t) assign("all_data", all_data, envir = .globalenv) cat("data input sucess\n") } #button assigned function window$env$butbrowse<- tk2button(window$env$rawtab, text ="please select data",width= -6, command= getdata) tkgrid(window$env$butbrowse,pady=10)
this basic setup allows user pick file , assigns variable. question can display file path after has been chosen in parent window?
thank help.
Comments
Post a Comment