[R-gui] embedding R graphics in Tk widgets
On Thu, 19 Jun 2008 02:14:18 +0000 (UTC),
jverzani <jverzani at gmail.com> wrote:
[...]
The handlers in the various toolkits have several different arguments, none of course being standard. The ... is to accommodate these. Whereas, the first argument for a handler, called "h" from the iWidgets background of gWidgets, is a list containing components "obj" to refer to the object that the handler is called on, such as the slider in your example, and "action" which just passes along the action= argument. (Some widgets have additional components, such as "dropdata" or "x" and "y".) The h$obj construction allows you to avoid global variables. So the following are equivalent:
sl = gslider(cont=gwindow(), handler = function(h,...) print(svalue(sl)))
and
sl = gslider(cont=gwindow(), handler = function(h,...) print(svalue(h$obj)))
Thanks for the explanation! On another note, I got a bit confused the other day trying to learn more about layout from the density example given in the vignette. I was trying to get the following layout: -------------- next part -------------- A non-text attachment was scrubbed... Name: density_layout.png Type: image/png Size: 6458 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-sig-gui/attachments/20080703/74926396/attachment.png> -------------- next part -------------- Basically, move the bandwidth slider below the graph and spanning the whole width of the window. Modifying the layout section of the code as: ---<---------------cut here---------------start-------------->--- window <- gwindow("gWidgetsDensity") bigGroup <- ggroup(container=window) vGroup <- ggroup(horizontal=FALSE, container=bigGroup) hGroup <- ggroup(horizontal=FALSE, container=bigGroup) tmp <- gframe("Distribution", container=vGroup) add(tmp, distribution) tmp <- gframe("Sample size", container=vGroup) add(tmp,sampleSize) tmp <- gframe("Kernel", container=vGroup) add(tmp,kernel) add(bigGroup, ggraphics()) tmp <- gframe("Bandwidth adjust", container=hGroup) add(tmp,bandwidthAdjust, expand=TRUE) ---<---------------cut here---------------end---------------->--- Why is the slider still packed side by side, when I'm specifying 'horizontal=FALSE' in hGroup? I also notice that one needs to do something in a widget to produce the initial plot, i.e. a default initial the plot is not produced. Thanks for any further pointers,
Seb