Bill S
Bill S

Reputation: 11

How do you close an rpanel panel from the program?

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).

library(rpanel)
panel <- rp.control(title = "Test")
rp.button(panel,"Close")

Edit on 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.

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)

Upvotes: 1

Views: 535

Answers (1)

IRTFM
IRTFM

Reputation: 263362

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:

Upvotes: 1

Related Questions