inst/examples/ex-glayout.R

if(interactive()) {

  w <- gwindow("glayout example", visible=FALSE)
  lyt <- glayout(cont=w)

  ## character -> glabel
  lyt[1,1] <- "Label"

  ## put lyt on both sides here (parent container on right)
  lyt[1,2] <- gedit("", cont=lyt)

  ## alignment options
  lyt[2,1, expand=TRUE, anchor=c(1,0)] <- "Label 2"

  lyt[2,2] <- gslider(cont=lyt)

  ## can reference children via [
  f <- function(h,...) {
    lst <- sapply(lyt[1:2, 2], svalue)
    print(lst)
  }
  
  ## stretch
  lyt[3, 1:2] <- gbutton("click me", cont=lyt, handler=f)

  visible(w) <- TRUE


}

Try the gWidgets2 package in your browser

Any scripts or data that you put into this service are public.

gWidgets2 documentation built on Jan. 11, 2022, 1:07 a.m.