I am trying to develop a GUI (using gWidgets) for an R package. My plan was to construct a main window holding the data, and with buttons calling small gui wrappers for each fun
You can pass information between gwidgets by using independent functions and without beforehand knowing the object name of the receiver widget:
initMain <- function() {
w <- gwindow(title="Main window",visible=FALSE)
txt <- gtext(text="Initial text in main window.",container=w)
btn <- gbutton("Send to sub window", container=w)
list(
run = function(partner) {
addHandlerChanged(btn, handler = function(h, ...) {
svalue(partner$txt) <- svalue(txt)
} )
visible(w) <- TRUE
},
txt = txt
)
}
initSubWindow<- function() {
w <- gwindow(title="Sub window",visible=FALSE)
txt <- gtext(text="huhu",container=w)
btn <- gbutton("Send to main window", container=w)
list(
run = function(partner) {
addHandlerChanged(btn, handler = function(h, ...) {
svalue(partner$txt) <- svalue(txt)
} )
visible(w) <- TRUE
},
txt = txt
)
}
mw <- initMain()
sw <- initSubWindow()
mw$run(sw)
sw$run(mw)