The gWidgets2 package

gWidgets2 is in maintenance-mode only. Currently only the tcltk version is viable, though likely gWidgetsWWW2 still works.

The gWidgets2 package is a rewrite of the gWidgets package that allows R users to easily create graphical user interfaces (GUIs) from within R in a toolkit-independent manner. The package itself sets up an API for describing these interfaces. An accompanying package integrates this into the underlying toolkit library.

Currently there are the following packages:

Additionally, for web programming the package gWidgetsWWW2 (ARCHIVED) implements basically the same API using the ExtJs JavaScript libraries.

The gWidgets2 API exposes only a small subset of what is available in the underlying toolkit, but does it in a fairly easy to learn way using many of R's standard methods, as possible.

A basic example of making a "hello world" app would be:

w <- gwindow("Hello...", visible=FALSE)       ## a parent container
g <- ggroup (cont = w)                        ## A box container
b <- gbutton("Click me for a message", cont=g, expand=TRUE)  ## some control

addHandlerClicked(b, function(...) {          ## adding a callback to an event
  gmessage("Hello world!", parent=w)          ## a dialog
})

visible(w) <- TRUE                            ## a method call

Though short, this example illustrates the range of basic tasks needed to construct a GUI. Some other examples are in the examples directory of the package and the package vignette.

Why a rewrite of the gWidgets package?