2008/8/11 Ben Bolker <[EMAIL PROTECTED]>:
>
> I can set up an entry widget (thanks to an old
> post by Barry Rowlingson) that gets a password and
> exits when the user clicks on the "OK" button.
Who? Oh dear, my past comes back to haunt me...
> getPassword <- function(){
> require(tcltk)
> tt <- tktoplevel()
> pass=tclVar("")
> label.widget <- tklabel(tt, text="Enter Password")
> password.widget <- tkentry(tt,show="*",textvariable=pass)
> ok <- tkbutton(tt,text="OK",default="active",
> command=function()tkdestroy(tt))
> tkpack(label.widget, password.widget,ok)
> tkwait.window(tt)
> return(tclvalue(pass))
> }
tkbind a function on the entry widget so that if <Return> is pressed
it destroys the window:
getPassword=function(){
require(tcltk)
tt <- tktoplevel()
pass=tclVar("")
label.widget <- tklabel(tt, text="Enter Password")
password.widget <- tkentry(tt,show="*",textvariable=pass)
tkbind(password.widget,"<Return>",function(){tkdestroy(tt)})
ok <- tkbutton(tt,text="OK",default="active",
command=function()tkdestroy(tt))
tkpack(label.widget, password.widget,ok)
tkwait.window(tt)
return(tclvalue(pass))
}
How's that? See you in a few years...
Barry
______________________________________________
[email protected] 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.