Extracing values of gedit in gbasicdialog

放肆的年华 提交于 2019-12-11 10:47:54

问题


I am trying to create a interface where the user can key in a number for the script to run. However, I am unable to retrieve the value keyed into gedit. Can anyone help me? Here's what I have done:

require(gWidgets2RGtk2) #Load package
w=gbasicdialog("key number")
a<-gedit("1",cont=w,handler=function(h,...){number<-svalue(a)})
visible(w)=TRUE

回答1:


Here I create , 2 gedit and update the value of one with the other value using a button:

w <- gwindow("test")
g <- ggroup(cont=w, horizontal=FALSE)
x <- gedit("20",cont=g)
gbutton("changevalue",cont=g,handler=function(h,...) {
  svalue(e) <- svalue(x)
})
e <- gedit("", cont=g)




回答2:


What I have done here is the same as suggested by jverzani

require(gWidgets2RGtk2) #Load package
 w = gbasicdialog("key number")
 a <- gedit("1",cont=w)
 addHandlerKeystroke(a, handler=function(h,..) { 

    number <- svalue(a)
    print(number)
 })
 visible(w)=TRUE


来源:https://stackoverflow.com/questions/21252493/extracing-values-of-gedit-in-gbasicdialog

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!