The RGtk package (version 0.8-0)

The RGtk package allows one to create Gtk and Gnome widgets from within R, using R functions and expressions. One can register S-language functions as callbacks for Gtk signals or events, allowing one to rapidly construct complex GUIs within R. The bindings to Gtk are generated automatically and this can be used to conveniently create interfaces to other Gtk-based libraries such as gnome, gtkhtml, gtkextra, and others.

There is a growing number of separate packages that provide bindings to other higher-level, add-on libraries for Gtk/Gnome. These include

  • RGtkHTML
    Access to the gtkhtml classes for rendering HTML within a Gtk widget.
  • RGtkExtra
    Access to a data-grid/spreadsheet like widget, a tree-like directory browser, and an icon list browser.
  • RGdkPixbuf
    Facilities for loading images from different formats and converting them to GtkPixbuf objects.
  • RGtkGlade
    Facilities for reading and instantiating interfaces created with the interactive GUI build, Glade.
  • RGnomePrint
    Printing facilities using libgnomeprint, including dialogs and preview mode with support for Postscript and Windows metafiles.
  • RGtkConsole
    An interactive terminal/console class for allowing user commands and output.
  • RGtkScrollpane
    A panner for simultaneously scrolling around 2D spaces.
  • Numerous more can be generated automatically using .defs files describing other different libraries such as zvt (the terminal widget), xmhtml, embedded mozilla, etc.

    Some high-level GUIs are available in the RGtkViewers package that are built using the RGtk package.

    One can also use this package in conjunction with the R gtkDevice package to create embedded graphics devices within GUIs. Some screen shots of simple ways to group multiple devices in a single window are available.

    This package provides similar capabilities as the Tcltk package but uses Gtk and the Gnome libraries as the underlying GUI toolkits. These toolkits are widely used and continually enhanced with new widgets and features. The RGtk package is constructed using a tool that automates the generation of the interface between R and the Gtk and Gnome libraries. Hence it is easy to update and extend to include new and enhanced libraries. The code generation tool is written primarily in R and uses the RSPython package to avail of the pygtk facility for parsing the defs files describing the classes and routines in the Gtk and Gnome libraries.


    The current version is available as a GNU-zipped tar file RGtk_0.8-0.tar.gz

    See the README and INSTALL files for instructions on using and installing the package.

    There is also an R gtkDevice package which allows one to create embedded graphics devices in R from arbitrary Gtk drawing area widgets. This also allows one to use Gtk devices independently of the Gnome GUI for R.


    There is currently no version for this package for Windows available. I have compiled one and it works. However, I need to enhance the event loop integration.


  • overview.
    Initial description of how to use the package.
  • FAQ
  • Generating the bindings
    Some notes on mechanism used to generate the bindings.
  • Embedded widgets in the Gtk HTML widget
    A brief description of a very powerful mechanism provided by the Gtk HTML widget to embed arbitrary widgets within it. This allows us to use R as a Java/Javascript-like language to create dynamic pages. This is similar to the SNetscape package
  • History of changes to the package.
  • Gtk
    The Gtk page provides tutorials and API references for the widgets and toolkit.
  • Books on Gtk.
    I have only looked at the first two of these.
  • PyGtk FAQ
    PyGTK provides similar bindings to Gtk for Python and the FAQ may provide useful information.
  • Examples

    There are currently a few examples

    Related Packages

    R plugin for Gnumeric
    A plugin for the Gnome spreadsheet Gnumeric. We can use RGtk to access and construct GUIs in Gnumeric since it is built using Gtk.
    An interface from R to GGobi. We can access the Gtk components of GGobi using RGtk. Additionally, GGobi has an extensive plugin mechanism which allows one to write plugins in the S language. One can add GUI components using RGtk. (See examples in the R plugin module for GGobi.)
    A plugin for Netscape that allows JavaScript code to call S functions and access S objects as well as allowing S to call JavaScript and communicate with other LiveConnect plugins.
    This package provides a mechanism for calling Python functions from R and vice-versa. This is used in the automated generation of the RGtk bindings between R and the C libraries of Gtk, Gnome, etc. We use the parser of the defs files provided by the pygtk interface.

    Duncan Temple Lang <>
    Last modified: Sat Sep 4 03:18:09 PDT 2004