Can't find tk2toplevel function in any R package

237 Views Asked by At

I am learning how to Develop GUI with R and found this nice tutorial.

library(tcltk2)
win3 <- tk2toplevel(title = "Tk2 window", manage = "grid", padx = 70, pady = 30)
win3$butOK <- tk2button(text = "OK", width = -6, command = TkCmd_destroy(parent))

However, the given code throws the following error:

Error in tk2toplevel(title = "Tk2 window", manage = "grid", padx = 70, : could not find function "tk2toplevel"

I looked the tcltk2 documentation and could not find the function tk2toplevel. I wonder if this function is coming from some other package.

1

There are 1 best solutions below

0
On

I agree with you; tk2toplevel is not available in tcltk2 and in any other package.
This is very strange.
In the help ?tk2widgets this function was never mentioned and the examples contained in this help suggest to use:

library(tcltk2)
win3 <- tktoplevel()
butOK <- tk2button(win3, text = "OK", width = -6, command = function() tkdestroy(win3))
tkgrid(butOK)

enter image description here