【发布时间】:2016-09-07 00:45:04
【问题描述】:
x <- gconfirm("Run Program?",title="gConfirm")
if (x){
w <- gwindow(title="List of Programs",visible=TRUE)
g = ggroup(horizontal = FALSE, cont=w)
glabel("Please select the Program", cont=g)
ptype <- c("A","B")
temp <- gcombobox(ptype , cont=g)
addHandlerChanged(temp , handler=function(...){})
gbutton("Run", cont=g,handler = function(...){
print(svalue(temp)
dispose(g)
runagain <- gconfirm("Run again?",title="gConfirm")
if(runagain){
## If user clicks okay, I want to start running again from the third line of the code, w <- gwindow......)**
}
}
任何人都可以暗示解决这个问题吗?另外,我如何将 svalue(temp) 显示到类似的 UI 框中,而不是在控制台上打印它。非常感谢任何帮助。
【问题讨论】:
-
首先,要显示 svalue(temp) 的 UI 框,您可以使用
gmessage(svalue(temp))。至于您关于重新运行代码的其他问题,您的意图是什么?是用另一个运行按钮打开一个全新的窗口吗? -
为什么每次都要创建/删除/创建组?控制是否发生变化?如果没有,只需使您的运行处理程序以
temp中选择的值为条件。 -
@jav 感谢您的回复。是的,我想再次运行同样的事情,只是 x 的值总是 True,所以我不想使用第一行的 gconfirm。
-
@jverzani 我希望再次能够从程序列表中选择一个程序,所以我需要从一开始就运行它,除了再次询问第一行“运行程序”。
标签: r user-interface gwidgets