Thanks Michael... I was working by analogy to the gbuttons, so I was trying to ³add² the gcheckboxgroup, which is apparently not necessary (due to, I guess, the intrinsic differences between the widgets). The index thing I was just screwed up on! I have it working now.
Nice package. Bryan On 6/27/09 8:25 AM, "Michael Lawrence" <mflaw...@fhcrc.org> wrote: > > > On Thu, Jun 25, 2009 at 8:29 AM, Bryan Hanson <han...@depauw.edu> wrote: >> Hi All... >> >> I¹m trying to build a small demo using gWidgets which permits interactive >> scaling and selection among different things to plot. I can get the widgets >> for scaling to work just fine. I am using gcheckboxgroup to make the >> (possibly multiple) selections. However, I can¹t seem to figure out how to >> properly define the gcheckboxgroup; I can draw the widget properly, I think >> my handler would use the svalue right if it actually received it. Part of >> the problem is using the index of the possible values rather than the values >> themselves, but I'm pretty sure this is not all of the problem. I've been >> unable to find an example like this in any of the various resources I've >> come across. >> >> BTW, report.which is really only there for troubleshooting. It works to >> return the values, I can't get it to return the indices, which are probably >> what I need in this case. >> >> A demo script is at the bottom and the error is just below. >> >>> > tmp <- gcheckboxgroup(stuff, handler = report.which, index = TRUE, >> + checked = c(TRUE, FALSE, FALSE, FALSE, FALSE), container = leftPanel) > > The above code should "define" the gcheckboxgroup. >> >>> > add(tmp, value = 1, expand = TRUE) > > I'm not sure what you are trying to add here. > >> >> Error in function (classes, fdef, mtable) : >> unable to find an inherited method for function ".add", for signature >> "gCheckboxgroupRGtk", "guiWidgetsToolkitRGtk2", "numeric" >> >> This error suggests that I don't have a method - I agree, but I don't know >> what goes into the method for gcheckboxgroup. >> >> For the sliders, it's clear to me how the actions and drawing of the widgets >> differ, but not so for gcheckboxgroup. >> >> A big TIA, Bryan >> ************* >> Bryan Hanson >> Professor of Chemistry & Biochemistry >> DePauw University, Greencastle IN USA >> >> Full Script: >> >> x <- 1:10 >> y1 <- x >> y2 <- x^2 >> y3 <- x^0.5 >> y4 <- y^3 >> df <- as.data.frame(cbind(x, y1, y2, y3, y4)) >> stuff <- c("y = x", "y = x^2", "y = x^0.5", "y = x^3") >> which.y <- 2 # inital value, to be changed later by the widget >> >> # Define a function for the widget handlers >> >> update.Plot <- function(h,...) { >> plot(df[,1], df[,svalue(which.y)], type = "l", >> ylim = c(0, svalue(yrange)), main = "Interactive Selection & Scaling", >> xlab = "x values", ylab = "y values") >> } >> >> report.which <- function(h, ...) { print(svalue(h$obj), index = TRUE) } > > > In the above handler, do you mean to pass the 'index' parameter to the > svalue() function? > >> >> >> # Define the actions & type of widget, along with returned values. >> # Must be done before packing widgets. >> >> yrange <- gslider(from = 0, to = max(y), by = 1.0, >> value = max(y), handler = update.Plot) >> which.y <- gcheckboxgroup(stuff, handler = report.which, index = TRUE, >> checked = c(TRUE, FALSE, FALSE, FALSE, FALSE)) >> >> # Assemble the graphics window & groups of containers >> >> mainWin <- gwindow("Interactive Plotting") >> bigGroup <- ggroup(cont = mainWin) >> leftPanel <- ggroup(horizontal = FALSE, container = bigGroup) >> >> # Format and pack the widgets, & link to their actions/type >> >> tmp <- gframe("y range", container = leftPanel) >> add(tmp, yrange, expand = TRUE) >> tmp <- gcheckboxgroup(stuff, handler = report.which, index = TRUE, >> checked = c(TRUE, FALSE, FALSE, FALSE, FALSE), container = leftPanel) >> add(tmp, value = 1, expand = TRUE) >> >> >> # Put it all together >> >> add(mainWin, ggraphics()) # puts the active graphic window w/i mainWin >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.