BUenas,

Quiero crear un GUI muy simple, el cual consiste en una ventana, que al abrirse 
tiene dos botones. El primer boton, copiar, es un boton que ejecutar�a 

datos<-read.table("clipboard",header=T,dec=",",sep="\t")

Y el segundo boton muestra todos los data.frames que hay en R

Para ello, estoy usando tcltk, por lo que hago lo siguiente:

require(tcltk)      
tt <- tktoplevel()  
tktitle(tt) <- "Mi primer programa"  

# Create a variable to keep track of the state of the dialog window:
#  If the window is active,                                            done = 0
#  If the window has been closed using the OK button,                  done = 1
#  If the window has been closed using the Cancel button or destroyed, done = 2
done <- tclVar(0)   # tclVar() creates a Tcl variable

# Create two buttons and for each one, set the value of the done variable
# to an appropriate value
OK.but <- tkbutton(tt, text = "  OK  ",
    command = function() tclvalue(done) <- 1)
Cancel.but <- tkbutton(tt, text = "Cancel",
    command = function() tclvalue(done) <- 2)

# Place the two buttons on the same row in their assigned window (tt)
tkgrid(OK.but, Cancel.but)

# Capture the event "Destroy" (e.g. Alt-F4 in Windows) and when this happens,
# assign 2 to done
tkbind(tt, "<Destroy>", function() tclvalue(done) <- 2)

tkfocus(tt)         # Place the focus to our tk window

# Do not proceed with the following code until the variable done is non-zero.
# (but other processes can still run, i.e., the system is not frozen)
tkwait.variable(done)

# The variable done is now non-zero, so we would like to record its value before
# destroying the window tt.  If we destroy it first, then done will be set to 2
# because of our earlier binding, but we want to determine whether the user
# pressed OK (i.e., see whether done is equal to 1)

doneVal <- as.integer(tclvalue(done))   # Get and coerce content of a Tcl 
variable
tkdestroy(tt)

# Test the result
if (doneVal == 1) {
datos<-read.table("clipboard",header=T,dec=",",sep="\t")
}
if (doneVal == 2) {
ls()
}


Esto funciona al crearlo en el script de R, pero el poortapapeles no me copia 
las celdas de excel, sino todo el c�digo anterior.

Podeis echarme una mano??

Gracias!!!
                                          
        [[alternative HTML version deleted]]

_______________________________________________
R-help-es mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-help-es

Responder a