[R] tkoptionmenu

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Mar 6 19:37:59 CET 2003


"janet rosenbaum" <jerosenb at hcs.harvard.edu> writes:

> 2.  I also have a tcltk in R question.  
> 
> How do you use the command tkoptionmenu in R?  
> 
> The following are both valid syntax and both create the desired menu, 
> but neither changes the variable fsep.
> 
> septype.menu <- tkoptionmenu(septype,fsep, ",",";", ".", "\t", " ", "")
> septype.menu <- tkoptionmenu(septype,variable=fsep, ",",";", ".", "\t", " ", "")
> 
> septype is the frame that optionmenu is placed in, and fsep is
> the variable whose value I want to change.  
> 
> I consulted with the tcltk documentation and none of their syntax or
> variations thereon works.  

What tkoptionmenu command?? I don't see one

> ls("package:tcltk", pattern="enu")
[1] "tkmenu"       "tkmenubutton"

Did you write one yourself, interfacing to tk_optionMenu? That's not
completely easy to get right. Or is there one in a contributed package?

In general "variable"-type arguments need to be objects of class
tclVar.

Something like this should work, but there are a few demons lurking
inside

tkoptionmenu <- function(...) tkcmd("tk_optionMenu", ...)
tt <- tktoplevel()
w <- .Tk.subwin(tt) # this is nasty! Is everything protected from GC??
fsep <- tclVar()
m <- tkoptionmenu(w, fsep, ",",";", ".", "\t", " ", "")
tkpack(w)
# select something
tclvalue(fsep)
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-help mailing list