A simple toplevel window with an OK button in R TclTk

# Load the tcltk package
require(tcltk)

# Create a new toplevel window
tt <- tktoplevel()

# Create a button whose function (command) is to destroy the window
OK.but <- tkbutton(tt,text="OK",command=function()tkdestroy(tt))

# Place the button on the window, using the grid manager.
tkgrid(OK.but)

# Now, bring the window to the focus, using tkfocus.  (This will not work
# if the code is run from RGui, because the focus will automatically
# return to RGui, but it will work if the code is copied and pasted into
# a script file and run using
# Rterm < scriptfile.R > scriptfile.Rout
tkfocus(tt)
Running the R code above gives the following window:


Pressing the OK button destroys the window.