RGtk2 RGtk2 logo

RGtk2 is a binding for R to the GTK2 library and dependent libraries. You can use it to construct arbitrarily complex GUI's from R. Your GUI can be integrated with other GTK GUI's such as that of GGobi via rggobi. It works on all three major platforms (Linux, Mac, and Windows). For more background on programming with GTK, see this tutorial.

Get RGtk2

The stable version of RGtk2 requires GTK version 2.8.0 or higher (and its dependencies). If you're on Linux, you probably already have GTK installed, though it might not be the latest version. There are GTK packages available for Mac OS X. If you're on Windows, download (exe, 6 meg) the automatic installer for the GTK runtime. If you want to access Libglade you'll need it installed as well (Libglade is included in the Windows runtime).

The latest stable RGtk2 package is available on CRAN. If you want to embed R graphics into your GUI, you need the cairoDevice package (also available on CRAN).

Quick Start

To get started, load the library and then execute a demo. For example:

> library(RGtk2)
> demo(appWindow)
> demo(package="RGtk2") # to see the rest

To draw R graphics inside an RGtk2 GUI:

> win = gtkWindow()
> da = gtkDrawingArea()
> win$add(da)
> asCairoDevice(da)
> plot(1:10)



RGtk2 2.10.5: Development version of RGtk2 that binds to GTK+ 2.10.x and supports extending GObject classes from R. Use install.packages("RGtk2", repos="http://www.ggobi.org/r") to try it, but beware - it is a beta development release.

cairoDevice 1.2: Many bug fixes, support for getGraphicsEvent().

RGtk2 2.8.7: Minor bugfix release, if I remember correctly.


demo(appWindow) on Linux:

Linux screenshot

demo(appWindow) on Windows:

Windows screenshot

Known Issues

The nature of the R event loop prevents the continuous execution of the GTK main loop, thus preventing things like timers and idle tasks from executing reliably. This manifests itself when using functionality such as GtkExpander and GtkEntryCompletion.

Bug Reports

Please report bugs to Michael Lawrence (user lawremi at the domain iastate.edu). Thanks.