I would like to close an rpanel panel by a button on the panel (through the "action" function that would be triggered by the rp.button statement below). I've read the rpanel documentation, but so far, the only way I can close the panel is to manually close the window itself (which doesn't allow me to perform other actions before the window/panel closes).
我想通过面板上的一个按钮关闭一个rpanel面板(通过下面的rp.button语句触发的“action”功能)。我已经阅读了rpanel文档,但到目前为止,关闭面板的唯一方法是手动关闭窗口本身(这不允许我在窗口/面板关闭之前执行其他操作)。
library(rpanel)
panel <- rp.control(title = "Test")
rp.button(panel,"Close")
Edit on 11/11/2010
编辑于11/11/2010
I must be blind. After going down many other paths, looking for some type of "destroy", "close", or "kill" function, I bumped into the "quitbutton" part of the rp.button() function. It's in the help file, however you have to scroll far to the right to find it.
我必须失明。在经历了许多其他路径,寻找某种类型的“破坏”,“关闭”或“杀死”功能后,我碰到了rp.button()函数的“quitbutton”部分。它位于帮助文件中,但是您必须向右滚动才能找到它。
Anyway, this means the above can be written as:
无论如何,这意味着上面可以写成:
library(rpanel)
do.before.close<-function(panel) {
print("Do stuff here")
panel
}
panel <- rp.control(title = "Test")
rp.button(panel,"Close", action=do.before.close, quitbutton = TRUE)
1 个解决方案
#1
1
I don't see that capability in the rpanel functions, but you should look at the TeachingDemos package function tkexamp. It creates a window that has an "Exit" button that calls the tkdestroy function. You should be able to take out the extraneous (to your purposes) material and put back material of your choosing. There is also a SIG for GUI developers:
我没有在rpanel函数中看到这个功能,但你应该看一下TeachingDemos包函数tkexamp。它创建了一个窗口,其中有一个“退出”按钮,可以调用tkdestroy函数。您应该能够取出无关的(用于您的目的)材料并放回您选择的材料。 GUI开发人员还有一个SIG:
#1
1
I don't see that capability in the rpanel functions, but you should look at the TeachingDemos package function tkexamp. It creates a window that has an "Exit" button that calls the tkdestroy function. You should be able to take out the extraneous (to your purposes) material and put back material of your choosing. There is also a SIG for GUI developers:
我没有在rpanel函数中看到这个功能,但你应该看一下TeachingDemos包函数tkexamp。它创建了一个窗口,其中有一个“退出”按钮,可以调用tkdestroy函数。您应该能够取出无关的(用于您的目的)材料并放回您选择的材料。 GUI开发人员还有一个SIG: