Login  Register

gWidgets return multiple selections

Posted by LCOG2 on Nov 20, 2014; 8:02pm
URL: https://support.nabble.com/gWidgets-return-multiple-selections-tp7592770.html

HI all,
  I am learning the gWidgets package and have not been able to pass or find a solution for my problem.  I want to create a dialogue box that pops up and asks the user to check some boxes and then store responses for each selection.  I can do this for a single selection but when I try multiple responses i get errors and I am not sure where I am going wrong.  

The thing I think i don;t understand is how to handle storing the multiple results selected?  Do I need to do this in the handler or after?

Some sample code:

#Load libraries
library(gWidgets)
library(RGtk2)


#Construct handler
Handler1 <- function(h,...){  
        label <- h$obj[]
        Selected. <<-  Selected. <<-Selected.[Selected.!=label]
       
}

#Open window
Window1 <- gwindow("Select Daily Descriptors") #Create list to store results Days. <- c("Day1","Day2","Day3") Outputs. <- rep(NA, length(Days.))
names(Outputs.) <- Days.
SelectionOptions. <- c("Bicycle Event1", "Construction Nearby","Path
Closure")


#Build column for every day
for(day in Days.){
        BigDataGroup <- ggroup(cont=Window1, horizontal = FALSE)
        Input1Group <-  gframe(day, container = Window1, horizontal=FALSE)
        Selected. <- SelectionOptions.
        #Create check box for each selection type
        for(select in SelectionOptions. ){
                gcheckbox(select,
                        container=Input1Group,
            checked=FALSE,
            handler= Handler1)
        }
        Outputs.[day] <- Selected.
}


Thanks in advance

Josh