require(tcltk) # Load the tcltk package tt <- tktoplevel() # Create a new toplevel window # Create a textbox OK.text <- tktext(tt, bg="white", height=20, width=80, wrap="none") # Create a button whose function (command) is to destroy the window OK.but <- tkbutton(tt, text = "OK", command = function() tkdestroy(tt)) # Place the textbox on the window, using the grid manager tkgrid(OK.text) # 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) print("Hello World ... is running") tkmessageBox(message="Hello World", icon="error")