Wednesday, February 29, 2012

Graphical message boxes with R package tcltk

Sometimes you just need a graphical messagebox....know what I mean? If only because it pops up in front of all the other open windows and alerts you to the fact that your R script is waiting for you to do something, or is finished doing something else.

The R package "tcltk" is the easiest way I have found to do this.  On Mac OSX you need to first install the Universal Tcl/Tk for X11(available here).  I haven't tried it on Windows, but I don't think this extra step is necessary.  Now just install the R package "tcltk" in the normal way, for example

install.packages("tcltk")
library("tcltk")

Now you should have access to functions like this.....
tk_messageBox(type="ok",message="I am a tkMessageBox!")


There are different types of messagebox (yesno, okcancel, etc). See ?tk_messageBox.

No comments:

Post a Comment