Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Initialisation de GTK *)
- let _ = GMain.init ()
- exception IsNone
- type 'a option =
- | None
- | Some of 'a
- (* Fenêtre principale de l'application. *)
- let window = GWindow.window
- ~title:"Project"
- ~height:700
- ~width:1000 ()
- (* Pack principal qui contient tous les widget *)
- let vboxall = GPack.vbox
- ~packing:window#add ()
- (* Pack dans lequel il y a la toolbar *)
- let box = GPack.vbox
- ~packing:vboxall#add ()
- let toolbar = GButton.toolbar
- ~orientation:`HORIZONTAL
- ~style:`ICONS
- ~packing:(box#pack ~expand:false) ()
- let item = GButton.tool_item ~packing:toolbar#insert ()
- (* Pack du milieu *)
- let mil = GPack.hbox
- ~packing:vboxall#add ()
- (* Pack de gauche *)
- let vbox = GPack.vbox
- ~height: 600
- ~packing:mil#add ()
- let separator = GMisc.separator `HORIZONTAL
- ~packing:(vbox#pack ~expand:false) ()
- (* Boutons *)
- let say_hello = GButton.button
- ~label:"Bonjour !"
- ~packing:(vbox#pack ~expand:false) ()
- (* Bouton pour up l'img *)
- let affiche btn =
- match btn with
- |Some n -> ignore (GMisc.image
- ~file: n
- ~packing:(vbox#pack ~expand:false) ())
- | _ -> raise IsNone
- let button =
- let btn = GFile.chooser_button
- ~title:"Browse"
- ~action:`OPEN
- ~packing:(item#add) () in
- btn#connect#selection_changed (affiche btn#filename);
- btn
- let button = GFile.chooser_button
- ~title:"Browse"
- ~action:`OPEN
- ~packing:item#add ()
- let display = Gaux.may ~f:image#set_file
- (* Pack de droite *)
- let vbox2 = GPack.vbox
- ~spacing:10
- ~border_width:10
- ~packing:mil#add ()
- let p2 = GButton.button
- ~label:"Bonjour !"
- ~packing:(vbox2#pack ~expand:false) ()
- (* Fonctions tests *)
- let print_hello () =
- let user = Glib.get_user_name () in
- Printf.printf "Bonjour %s !\n%!" (String.capitalize user)
- let _ =
- window#connect#destroy ~callback:GMain.quit;
- say_hello#connect#clicked ~callback:print_hello;
- button#connect#selection_changed (fun () -> display button#filename);
- p2#connect#clicked ~callback:print_hello;
- window#show ();
- GMain.main ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement