Skip to content
Prev 758 / 1236 Next

[R-gui] Request for users of my R-Tcl/Tk examples,

Indra B. Kshattry wrote:
Do you mean something like this? I am a newbie with R's tcltk too.

library(tcltk)

tt <- tktoplevel() 
input.widget <- tkentry(tt)
output.widget <- tkentry(tt)
tkinsert(input.widget, "end", "4")
tkinsert(output.widget, "end", "24")

gui.fat <- function() {
  n <- as.integer(tclvalue(tkget(input.widget)))
  fat.n <- prod(1:n)
  tkdelete(output.widget, 0, "end")
  tkinsert(output.widget, "end", fat.n)
}

button.widget <- tkbutton(tt, text="fat() =", command = gui.fat) 
tkpack(input.widget, button.widget, output.widget) # geometry manager 
 
Alberto Monteiro