The following code demonstrates a simple "Hello World" message box.
require(tcltk) ReturnVal <- tkmessageBox(title="Greetings from R TclTk",message="Hello, world!",icon="info",type="ok")

After pressing the OK button, we can check the return value of the message box function.
ReturnVal <Tcl> ok tclvalue(ReturnVal) [1] "ok" as.character(ReturnVal) [1] "ok"
We notice that the window size for the message box is too small to display the full title in the title bar,
and unfortunately message boxes are not resizable by default (whereas tktoplevel windows are resizable by
default). A simple way to fix this (which is admittedly not very elegant), is to add spaces on the end of
the message to make it at least as long as the title.
require(tcltk) ReturnVal <- tkmessageBox(title="Greetings from R TclTk",message="Hello, world! ",icon="info",type="ok")

Of course, sometimes it is desirable to have other buttons and/or other icons in a message box. The following examples illustrate some typical choices of buttons and icons.
require(tcltk) tkmessageBox(message="An error has occurred!",icon="error",type="ok")

require(tcltk) tkmessageBox(message="This is a warning!",icon="warning",type="ok")

require(tcltk) tkmessageBox(message="Do you want to save before quitting?",icon="question",type="yesnocancel",default="yes")
