Search code examples
rgwidgets

multiple inputs in a same form gwidgets2


I am trying to put several ginputs into a form in gWidgets2, or to get the text entered in a gedit widget as a list or something to use in the rest of the code,

library(gWidgets2)
options(guiToolkit = "tcltk")

prj_name   = ginput("Project name")
user = ginput("User name")
transfer = ginput("Transfer amount")

I tried with gformlayout but they ginput apparently can't be contained in one; and I haven't found how to pass the inputs on the widget to an object (a list in this case) in R


Solution

  • ginput is a dialog. The widget you want is gedit. This example is from the help page of gformlayout

     w <- gwindow("gformlayout", visible=FALSE)
         g <- gvbox(container=w)
         
         flyt <- gformlayout(container=g)
         gedit("", label="Name:", container=flyt)
         gedit("", label="Rank:", container=flyt)
         gedit("", label="Serial No.:", container=flyt)
         
         b <- gbutton("Show me", container=g, handler=function(h,...) {
         print(svalue(flyt))
         })
         
         addSpring(g) 
         visible(w) <- TRUE