Re: [R] use gcheckbox in gWidgets to switch on/off gframe

2016-01-22 Thread Rolf Fankhauser

Hi Tonja

Maybe I wasn't clear in my last post. This is the code:

library(gWidgetstcltk)
library(gWidgets)
options(guiToolkit="tcltk")
Population <- c("A","B","C","D","E","F")
w = gwindow("")
g1 = ggroup(horizontal = F, cont=w)
g2 = ggroup(horizontal = T, cont=g1)
glabel("Population:", cont=g2)
Station = gcombobox(Population, editable=F, cont=g2, handler=NULL)
gseparator(horizontal=T, container=g1, expand=F)
gcheckbox("checked", checked=T, container=g1, handler=function(h,...) {
enabled ( frame1 ) <- svalue(h$obj)
})
frame1 <- gframe ( "A:" , cont = g1 , horizontal=FALSE )
lyt1 <- glayout ( cont = frame1)
widget_list <- list ( )
lyt1 [1,1] <- "A1:"
lyt1 [1,2,expand = TRUE] <- (widget_list$A1 <- gedit(" ", cont=lyt1, 
handler=NULL))

lyt1 [2,1] <- "A2:"
lyt1 [2,2,expand = TRUE] <- (widget_list$A2 <- gedit(" ", cont=lyt1, 
handler=NULL))

gcheckbox("checked", checked=T, container=g1, handler=function(h,...) {
enabled ( frame2 ) <-  svalue(h$obj)
})
frame2 <- gframe ( "B:" , cont = g1 , horizontal=FALSE )
lyt2 <- glayout ( cont = frame2)
widget_list <- list ( )
lyt2 [1,1] <- "B1:"
lyt2 [1,2, expand = TRUE] <- (widget_list$B1 <- gedit(" ", cont=lyt2, 
handler=NULL))


Regards, Rolf

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] use gcheckbox in gWidgets to switch on/off gframe

2016-01-16 Thread Rolf Fankhauser

Hi Tonja

I removed the cat(...) in the event handlers because cat writes TRUE or 
FALSE to the console but doesn't seem to return a value.
Then it worked. You should initialize the frames to be disabled or the 
checkboxes to be checked that both states are consistant.


Regards, Rolf


tonja.krue...@web.de wrote:


Dear All,
I’m trying to create a GUI using gWidgets.
I would like to have a checkbox to “switch on/off” different frames within the 
GUI. Ideally if one frame is switched on, all other frames would be switched 
off.
Unfortunatly I only came as far as this:

library(gWidgets)
Population <- c("A","B","C","D","E","F")
w = gwindow("")
g1 = ggroup(horizontal = F, cont=w)
g2 = ggroup(horizontal = T, cont=g1)
glabel("Population:", cont=g2)
Station = gcombobox(Population, editable=F, cont=g2, handler=NULL)
gseparator(horizontal=T, container=g1, expand=F)
gcheckbox("checked", container=g1, handler=function(h,...) {
enabled ( frame1 ) <-  cat(svalue(h$obj))
})
frame1 <- gframe ( "A:" , cont = g1 , horizontal=FALSE )
lyt1 <- glayout ( cont = frame1)
widget_list <- list ( )
lyt1 [1,1] <- "A1:"
lyt1 [1,2,expand = TRUE] <- (widget_list$A1 <- gedit(" ", cont=lyt1, 
handler=NULL))
lyt1 [2,1] <- "A2:"
lyt1 [2,2,expand = TRUE] <- (widget_list$A2 <- gedit(" ", cont=lyt1, 
handler=NULL))
gcheckbox("checked", container=g1, handler=function(h,...) {
enabled ( frame2 ) <-  cat(svalue(h$obj))
})
frame2 <- gframe ( "B:" , cont = g1 , horizontal=FALSE )
lyt2 <- glayout ( cont = frame2)
widget_list <- list ( )
lyt2 [1,1] <- "B1:"
lyt2 [1,2, expand = TRUE] <- (widget_list$B1 <- gedit(" ", cont=lyt2, 
handler=NULL))

When I type in:
enabled ( frame2 ) <-  F; enabled ( frame2 ) <-  T
it does what I would like it to do. But when I check the checkbox it will only 
work once. Thank you for any suggestions!
Tonja

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



--
Rolf Fankhauser
Hegenheimerstrasse 129
4055 Basel
Tel. 061 321 45 25

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.