package bogue
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=319b9ca87ff90110c71220cca79b0742
sha512=d196e3121846042f68ddbbad2ea6310a3035199cfae06e115fffa03f6929ecb61e1b2364b323e1379592cdc4bf4764c011002b004cf5acf4f1fcff21a68e829d
doc/bogue/Bogue/index.html
Module BogueSource
General purpose GUI (Graphical user interface) library for Ocaml.
Bogue is a lightweight and fast GUI for developing desktop applications, games, or for easy debugging of non-GUI programs.
Bogue is entirely written in ocaml except for the hardware accelerated graphics library SDL2.
Quick start
For a quick start, see Bogue's general principles, and the minimal example.
The main modules are
Main(creating, running, and quitting your app),Layout(arranging widgets to form sophisticated interfaces like table, menus, etc.) andWidget(the building blocks, like labels, buttons, etc.).
indexlist
List of Modules
The only thing that open Bogue does is to bring these modules into your namespace. The have quite common names, so beware of conflict. In case of doubt, don't open Bogue, and access to the modules by using the Bogue prefix, for instance Bogue.Widget.label. The Widget and Layout modules are probably the ones that you will find yourself using the most, so it's a good idea to alias them:
module W = Bogue.Widget
module L = Bogue.LayoutWidgets
Widgets are building blocks of the GUI. They also receive all events (mouse focus, etc.) and contain the intelligence of your GUI, through connections (or callbacks, see Widget.connection). However, in order to be displayed, they need to be packed into layouts (Layout.t).
The main module for dealing with widgets is Widget.
Multi-line text display widget
One-line text-input widget
Layouts
Layouts are rectangular graphical placeholders, in which you should pack all your widgets in order to display your GUI. Sophisticated gadgets are usually obtained by combining several layouts together.
The Bogue mainloop
Because a GUI continuously waits for user interaction, everything has to run inside a loop.
Example
Here is a minimal example with a label and a check box.
open Bogue
module W = Widget
module L = Layout
let main () =
let b = W.check_box () in
let l = W.label "Hello world" in
let layout = L.flat_of_w [b;l] in
let board = Bogue.make [] [layout] in
Bogue.run board;;
let () = main ();
Bogue.quit ()This can be compiled to bytecode with
ocamlfind ocamlc -package bogue -linkpkg -o minimal -thread minimal.ml
and to native code with
ocamlfind ocamlopt -package bogue -linkpkg -o minimal -thread minimal.ml
Then execute the compiled code:
./minimal
A window should open which should look like this:

You may also evaluate this code in a Toplevel! (for instance utop, or in an emacs session...). Just insert
#thread;; #require "bogue";;
at the top, then paste the example code above, and add ;; at the end.