# NOT RUN {
w <- gwindow("stack widget", visible=FALSE)
add_page <- function(cont, i) {
g <- gvbox(container=cont)
glabel(sprintf("page %s",i), container=g)
bg <- ggroup(container=g); addSpring(bg)
lb <- gbutton("Previous", container=bg, handler=function(h,...) {
svalue(cont) <- max(1, i - 1)
})
rb <- gbutton("Next", container=bg, handler=function(h,...) {
svalue(cont) <- min(i + 1, length(cont))
})
}
sw <- gstackwidget(cont=w)
sapply(1:5, add_page, cont=sw)
visible(w) <- TRUE
# }
Run the code above in your browser using DataLab