(************************************************************ get_password.ml Created : Sun Mar 2 18:01:49 2003 Last modified: Sun Mar 02 18:08:10 2003 Compile: ocamlc.opt -I +labltk labltk.cma get_password.ml -o get_password # FTP Directory: sources/ocaml # ************************************************************) (** @author Takashi Masuyama *) open Tk let get_password message = let window = openTk () in let label = Label.create ~text:message window in let e = Entry.create ~show:'*' ~width:10 ~state:`Normal window in let end_function event = begin print_endline ("password is "^(Entry.get e)); flush stdout; closeTk () end in begin (* キーの名前は /usr/include/X11/keysymdef.h を参考にする*) bind ~events:[`KeyPressDetail("Return")] ~extend:false ~action:end_function e; pack ~side:`Top [label]; pack ~side:`Top [e]; mainLoop () end let _ = get_password "Enter password"