solares@unsl.edu.ar
2003-Sep-08 12:38 UTC
[R] add checkbutton and the variable(wrong length of vector "b")
Hello it wanted to add a boton of checkup in a menu, ?How I do to create so many variables as checkbutton? I try with the code that continues, use a vector that is charged dynamicamente while I open files but the component of vector "b" is associates with a Tcl variable and load 3 components (environment, value and pointer) I wanted alone to charge the value (0 done not select and 1 selected), and the length its wrong. Good, here are the script so that they see it. Thanks Ruben library(tcltk) vectPath<-c() b<-c() archivos<-function(){ f<-tkcmd("tk_getOpenFile") temparch<-tclvalue(f) assign("vectPath",c(vectPath,temparch),.GlobalEnv) temp<-0 assign("b",c(b,temp),.GlobalEnv) #charge the variable for the checkbutton cant<-length(vectPath) j<-vectPath[cant] tkadd(m, "check", label=j, variable=b[cant]) #add the variable } ver<-function(){ i<-1 while (i<=length(b)) { #the length of b is wrong!! print(tclvalue(b[i])) i<-i+1 } } borra<-function(){ assign("vectPath",c(),.GlobalEnv) assign("b",c(),.GlobalEnv) tkdelete(m,"0","end") } tt <- tktoplevel() tkpack(mb <- tkmenubutton(tt, text="Datos")) m <- tkmenu(mb,tearoff=FALSE) tkconfigure(mb,menu=m) b<-tkbutton(tt,text="abrir",command=function()archivos()) tkpack(b) b3<-tkbutton(tt,text="ver",command=function()ver()) tkpack(b3) b4<-tkbutton(tt,text="Borrar",command=function()borra()) tkpack(b4)
solares@unsl.edu.ar
2003-Sep-08 12:39 UTC
[R] add checkbutton and the variable(wrong length of vector "b")
Hello it wanted to add a boton of checkup in a menu, ?How I do to create so many variables as checkbutton? I try with the code that continues, use a vector that is charged dynamicamente while I open files but the component of vector "b" is associates with a Tcl variable and load 3 components (environment, value and pointer) I wanted alone to charge the value (0 done not select and 1 selected), and the length its wrong. Good, here are the script so that they see it. Thanks Ruben library(tcltk) vectPath<-c() b<-c() archivos<-function(){ f<-tkcmd("tk_getOpenFile") temparch<-tclvalue(f) assign("vectPath",c(vectPath,temparch),.GlobalEnv) temp<-0 assign("b",c(b,temp),.GlobalEnv) #charge the variable for the checkbutton cant<-length(vectPath) j<-vectPath[cant] tkadd(m, "check", label=j, variable=b[cant]) #add the variable } ver<-function(){ i<-1 while (i<=length(b)) { #the length of b is wrong!! print(tclvalue(b[i])) i<-i+1 } } borra<-function(){ assign("vectPath",c(),.GlobalEnv) assign("b",c(),.GlobalEnv) tkdelete(m,"0","end") } tt <- tktoplevel() tkpack(mb <- tkmenubutton(tt, text="Datos")) m <- tkmenu(mb,tearoff=FALSE) tkconfigure(mb,menu=m) b<-tkbutton(tt,text="abrir",command=function()archivos()) tkpack(b) b3<-tkbutton(tt,text="ver",command=function()ver()) tkpack(b3) b4<-tkbutton(tt,text="Borrar",command=function()borra()) tkpack(b4)