6 let enter_callback entry =
7 printf "Entry contents: %s\n" entry#text;
10 let entry_toggle_editable button entry =
11 entry#set_editable button#active
13 let entry_toggle_visibility button entry =
14 entry#set_visibility button#active
18 let window = GWindow.window ~title: "GTK Entry" ~width: 200 ~height: 100 () in
19 window#connect#destroy ~callback:Main.quit;
21 let vbox = GPack.vbox ~packing: window#add () in
23 let entry = GEdit.entry ~max_length: 50 ~packing: vbox#add () in
24 entry#connect#activate ~callback:(fun () -> enter_callback entry);
25 entry#set_text "Hello";
26 entry#append_text " world";
27 entry#select_region ~start:0 ~stop:entry#text_length;
29 let hbox = GPack.hbox ~packing: vbox#add () in
31 let check = GButton.check_button ~label: "Editable" ~active: true
32 ~packing: hbox#add () in
33 check#connect#toggled ~callback:(fun () -> entry_toggle_editable check entry);
36 GButton.check_button ~label:"Visible" ~active:true ~packing:hbox#add () in
38 ~callback:(fun () -> entry_toggle_visibility check entry);
40 let button = GButton.button ~label: "Close" ~packing: vbox#add () in
41 button#connect#clicked ~callback:window#destroy;
42 button#grab_default ();