[R-gui] [R GUI] validate for entries

Erin Hodgess hodgess at gator.uhd.edu
Thu Apr 22 07:57:10 CEST 2004


Dear R Gui People:

I'm trying to put together a little project to enter values for binomial
probabilities.

Right now, I'd like to validate each entry as I go along.

I'm stuck on the validate function.  I'm using Iwidgets of entryfield.

Here is the code:
require(tcltk)
tclRequire("Iwidgets")
tt <- tktoplevel()
tkwm.title(tt,"Binomial Days")
Trial <- tclVar(0)
Success <- tclVar(0)
Percent <- tclVar(0.00)
fs1 <- function() tkfocus(succ)
fs2 <- function() {
	NumTrial <- as.numeric(unlist(trial))
	if(NumTrial <=0 || NumTrial > 20) {
	tkgrid(tklabel(tt),text="Invalid Number of Trials")
	}
}
trial <- tkwidget(tt,"iwidgets::entryfield",labeltext="Number of Trials",
	labelpos="nw",command=fs1,validate=fs2)
succ <- tkwidget(tt,"iwidgets::entryfield",labeltext="Number of Successes",
	labelpos="nw")
tkpack(trial)
tkpack(succ)
bb <- tkwidget(tt, "iwidgets::buttonbox")
cb <- tkwidget(tt, "iwidgets::radiobox", labeltext="Direction Options",
	labelpos="nw")
Can1 <- function() tkdestroy(tt)
tkadd(cb,"gt",text="Greater Than")
tkadd(cb,"gte",text="Greater Than or Equal to")
tkadd(cb,"lt",text="Less Than")
tkadd(cb,"lte",text="Less Than or Equal to")
tkadd(cb,"eq",text="Equal To")
tkselect(cb,"eq")
tkadd(bb,"OK",text="OK",command=quote(cat("OK\n")))
tkadd(bb,"Cancel",text="Cancel",command=Can1)
tkpack(cb,expand="yes")
tkpack(bb,expand="yes")




Any ideas would be greatly appreciated.  I'm sure that it's something
completely stupid.

Thanks,
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: hodgess at gator.uhd.edu



More information about the R-SIG-GUI mailing list