R gWidgets remove parameters and passing arguments -
R gWidgets remove parameters and passing arguments -
i’m new r world , i’m having difficulties working gwidgets , hope out there can help me. first of r version 2.15.2., , i’m using windows 7 32-bit.
i want create gui input/output , selection (yes, no), if user selects (using gradio) “yes”, display set of parameters, if “no”, should disappear (those parameters), or grayness out. , finally, if user click ok button, pass parameters utilize (later on) phone call function. here questions:
do have thought how can remove parameters when user selects “no”, right now, if click no, prints want, when click “yes” again, displays 3 parameters. do know how can pass arguments when user click “ok”, later when click ok, phone call (or source) function in different r codemany in advance help
cesar
p.s. below code:
require(gwidgets) options("guitoolkit"="rgtk2") #options(expressions=500000) w <- gwindow("") g <- ggroup(horizontal = false, container = w) glabel("input/output", container = g) inputfiledir <- gfilebrowse (text = "select file...", type = "open", quote = false, filter = list("text file" = list(patterns = c("*.txt"))), container = g) svalue(inputfiledir) outputfiledir <- gfilebrowse (text = "input file name...", type = "save", quote = false, filter = list("text file" = list(patterns = c("*.txt"))), container = g) svalue(outputfiledir) glabel("direction?", container = g) dirselec <- c("yes","no") rbf <- function(h,...){ if (svalue(h$obj, index=true) == 1){ print ( "define handler here" ) glabel("meridional (raster file):", container = g) fieldconstraindir_v <- gedit("", container = g, default = 0) svalue(fieldconstraindir_v) glabel("zonal (raster file):", container = g) fieldconstraindir_u <- gedit("", container = g, default = 0) svalue(fieldconstraindir_u) glabel("max. angle:", container = g) maxang <- gedit("", width = 3, initial.msg = "paste path raster file (no extensions)", default = 0, container = g) svalue(maxang) }else { #(svalue(h$obj, index=true) == 2) print ( "when user click no, needs go or grayness out" ) } } rb <- gradio(dirselec, container = g) selected = svalue(rb, index=true) <- 2 rbh <- addhandlerclicked(rb, handler = rbf) bg <- ggroup(container = g) addspring(bg) onok <- function(h,...){ print(svalue(inputfiledir)) #chartr("\\", "/", print(svalue(inputfiledir))) print(svalue(outputfiledir)) print(svalue(fieldconstraindir_v)) print(svalue(fieldconstraindir_u)) print(svalue(maxang)) } gbutton(" ok ", container = bg, handler = onok) gbutton(" cancel ", container=bg, handler = function(h,...) dispose(w))
you have various options:
you can place parameters gexpandgroup widget , phone call visible<- method on this. toggle showing them.
within gwidgetsrgtk2, can create widgets in (child) container not attached parent container (no cont=... in constructor), add(parent, child) add together , delete(parent, child) remove. shouldn't delete widgets in rm sense, remove them screen
you can place parameters container , phone call enabled<- false "gray" them out.
the first 2 may require screen size management.
in cases, kid controls still settable , readable during program, should have default values there or checking when utilize them.
as passing parameters way within r set command widgets list, l. idiom
out <- sapply(l, svalue) bundles them list can passed function. do.call function makes easy work lists arguments.
r gwidgets
Comments
Post a Comment