0

I am practicing gui in r, and made simplest code here. I made simple layout with text, entry and button, and tried to implement a function that is connected to the button. below is the code i tried. and I got error message on function tkcmd like "Error in tkcmd("tk_getOpenFile") : can't find function tkcmd". Is there any other libraries to use tkcmd?

    library(tcltk)

guiPractice <- function() {
  tt<- tktoplevel()
  lbl <- tklabel(tt, text="GUI PRACTICE")
  tkpack(lbl)
  
  exit <- function() {
    tkdestroy(tt)
  }
  srch <- function() {
    file <- tkcmd("tk_getOpenFile")
    if (!length(file)) return()
    chn <- tkcmd("open", file, "r")
    tkinsert(txt, "0.0", tkcmd("read", chn))
    tkcmd("close", chn)
    wfile <<- file
  }
  srch.but <-tkbutton(tt, text="Search", command=srch)
  e.srch <-tkentry(tt, width=20)
  tkpack(e.srch, srch.but)
  
  txt <- tktext(tt, height=10)
  tkpack(txt)

  but<-tkbutton(tt, text="Exit", command=exit)
  tkpack(but)
}
jay
  • 99
  • 6
  • My guess is that you're not loading all the dependencies or maybe the function has been deprecated in newer versions of tcltk. What is the source of this code? – Roman Luštrik Aug 28 '20 at 06:48
  • @RomanLuštrik i googled load function and others are from https://pdfs.semanticscholar.org/a9fe/267f67790279b55b141d57e0c943e339686b.pdf – jay Aug 28 '20 at 07:48
  • 1
    This is nearly 20 years old and it would be a safe bet to say that that function has been deprecated. Go through the changelog of the package to see if you get any hints on what happened to the function and/or if it has a successor. – Roman Luštrik Aug 28 '20 at 08:13

0 Answers0