#Two libraries that will be needed are the RGtk and gtkDevice. # The gtkDevice gives us the ability to plot to drawing area in a Gtk object library(RGtk) library(gtkDevice) layouts = function(){ # The window object is created with a call to gtkWindow. # which is a top level window that can hold other widgets. # The Gtk Functions begin with "gtk" and their names correspond # to the those found in the Gtk API at http://www.gtk.org/api/2.6/gtk/index.html win = gtkWindow() # The v box is a vertical box to contain widgets # We can't put the buttons and such straight into a window, they # need to contained in boxes, which determine how the GUI is laid out # We add the vbox to the window with the Add method associated with the vbox vbox = gtkVBox() win$Add(vbox) # Create a graphics device to put in the GUI histPlot <- gtkDrawingArea() asGtkDevice(histPlot) # To add widgets to boxes we use either the PackStart or PackEnd method # to pack widget from the top down or bottom up, respectively vbox$PackStart(histPlot) # This is the button that will start the simulation goBtn = gtkButton("Start Simulation") vbox$PackEnd(goBtn, FALSE, FALSE) } # Notice that this function lays out a GUI, but when the button is clicked # nothing happens. To make something happen we need to connect an R function # to the click event, i.e. when the button is clicked, then the function is # called. See the next set of sample code for ideas on this.