Hi Greg and jverzaniNWBKZ, thank you very much for your help. I already thought about your solution jverzaniNWBKZ. I hoped I could find a simpler solution (such as refering to the global variable of scale). As this is not possible for some intervals, I will take your solution.
Thanks again for the quick answers!!! jverzaniNWBKZ wrote > > Greg Snow <538280 <at> gmail.com> writes: > >> >> I believe that what is happening is that when you try to edit the >> entry widget any intermediate values get sent to the slider widget >> which then checks to see if they are in the allowable range and if it >> is not then it sets the value to either the minimum and maximum and >> sends that back to the entry widget while you are still trying to edit >> it. Even if you highlight a single digit and try to replace it with a >> different digit it first deletes the highlighted digit resulting in a >> number smaller than the minimum of the slider which then updates the >> entry widget to the minimum before the new digit can go in, then >> adding the new digit makes it larger than the slider maximum. >> > > Greg is right. You might try validating on focusout, rather than the key, > but this is easy enough to do in R code, rather than let tcl do that work: > > a <- 306870; b <- 3026741 > > tt<-tktoplevel() > varalpha <- tclVar(a) > charalpha <- tclVar(as.character(a)) > > > scale <- tkscale(tt, from=a, to=b, resolution=1, label="alpha", > variable=varalpha, > showvalue=TRUE, orient="horiz") > ed <- tkentry(tt, textvariable=charalpha) > > tkpack(ed) > tkpack(scale) > > ## connect > tkconfigure(scale, command=function(...) { > tclvalue(charalpha) <- as.character(tclvalue(varalpha)) > }) > > valid_input <- function(...) { > val <- as.numeric(tclvalue(charalpha)) > if(a <= val & val <= b) { > message("set to ", val) > tclvalue(varalpha) <- val > } else { > message("not valid...") > tkfocus(ed) > } > } > > tkbind(ed, "<Return>", valid_input) > tkbind(ed, "<FocusOut>", valid_input) > > ______________________________________________ > R-help@ 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. > -- View this message in context: http://r.789695.n4.nabble.com/set-tkscale-by-tkentry-tp4631174p4631281.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.