Hello,

 

I'm migrating an old S application to R, and having trouble passing
tk2listbox selections to a function. Could not find a listbox example
with tcltk2, just tcltk. The snippet below shows a few of the lines
creating the gui, including a tk2entry box that works fine for passing
content, and a tk2listbox that doesn't, and the button calling the
function. Right now I'm just passing the default values for any listbox
(OSType in the example below). I can't figure out how to pass a user
selection. Have tried variations with
tkcurselection(OSlist),tclGetValue(OSlist). How do I obtain the value
from OSlist if "Simple Random" was selected by the user? 

 

OtofanR=tktoplevel()

tktitle(OtofanR) <- "Age-Related Data Analysis with OTOFAN"

tkgrid(tklabel(OtofanR,text="DATA SELECTION & DEFINITION"),stick="we")

.

.

.

FreqVar <- tclVar("NA")

tkgrid(tklabel(OtofanR,text="Frequency variable"),tk2entry(OtofanR,
textvariable=FreqVar, width=20))

OSType <- tclVar("Random at Length")

OSlist=tk2listbox(OtofanR, values=c("Random at Length", "Simple
Random"), value=OSType, selection=1, selectmode = "single", height = 2,
scroll = "none", autoscroll = "x", enabled = TRUE)

tkgrid(tklabel(OtofanR,text="Otolith Sample Type"),OSlist)

.

.

.

AppApply <- tk2button(OtofanR, text = "Apply", width = 7, command =
function()
OtofanDT(tclvalue(ADMBdata),tclvalue(ADMBFile),tclvalue(ADMBPin),ADMBF="
NA",ADMBP="NA",tclvalue(GS),tclvalue(Regdata),tclvalue(CustomFile),

 
tclvalue(Ages),tclvalue(FishLens),tclvalue(OtoWts),tclvalue(OtoLens),tcl
value(FishWts),tclvalue(GroupID),tclvalue(YearID),tclvalue(Sex),tclvalue
(LFdata),tclvalue(FreqVar),tclvalue(OSType),tclvalue(ASType),

 
tclvalue(LAAdet),tclvalue(LPhase),tclvalue(Ldist),tclvalue(LAAstdev),tcl
value(LSDPhase),tclvalue(LSDdist),tclvalue(LSDcov),tclvalue(OAA),tclvalu
e(OAAdet),tclvalue(OPhase),tclvalue(Odist),tclvalue(OAAstdev),tclvalue(O
SDPhase),tclvalue(OSDdist),

 
tclvalue(CORR),tclvalue(CORest),tclvalue(CPhase),tclvalue(GS2),tclvalue(
PAAPhase)))

 

Mark Fowler 
Population Ecology Division 
Bedford Inst of Oceanography 
Dept Fisheries & Oceans 
Dartmouth NS Canada 
B2Y 4A2 
Tel. (902) 426-3529 
Fax (902) 426-9710 
Email mark.fow...@dfo-mpo.gc.ca <mailto:mark.fow...@dfo-mpo.gc.ca>  



 


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to