The labltk library provides access to the Tcl/Tk GUI from OCaml programs. This interface is generated in an automated way, and you should refer to Tcl/Tk books and man pages for detailed information on the behavior of the numerous functions. We also suggest to use ocamlbrowser to see the types of the various functions, that are the best documentation for the library itself.
Programs that use the labltk library must be linked as follows:
ocamlc other options -I +labltk labltk.cma other files ocamlopt other options -I +labltk labltk.cmxa other files
Unix: The labltk library is available for any system with Tcl/Tk installed, starting from Tcl 7.5/Tk 4.1 up to Tcl/Tk 8.4. Beware that some beta versions may have compatibility problems.If the library was not compiled correctly, try to run again the configure script with the option -tkdefs switches, where switches is a list of C-style inclusion paths leading to the right tcl.h and tk.h, for instance "-I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4".
A script is installed, to make easier the use of the labltk library as toplevel.
- labltk
- This is a toplevel including the labltk library, and the path is already set as to allow the use of the various modules. It also includes code for the Unix and Str libraries. You can use it in place of ocaml.
Windows: The labltk library has been precompiled for use with Tcl/Tk 8.4. You must first have it installed on your system. It can be downloaded from
http://www.activestate.com/products/ActiveTcl/. After installing it, you must put the dynamically loaded libraries tcl84.dll and tk84.dll (from the bin directory of the Tcl installation) in a directory included in you path.No toplevel is available, but you can load the library from the standard toplevel with the following commands.
# #directory "+labltk";; # #load "labltk.cma";;You can also load it directly from the command line.
C:\ocaml\bin> ocaml -I +labltk labltk.cma
The labltk library is composed of a large number of modules.
Bell Imagebitmap Place Button Imagephoto Radiobutton Canvas Label Scale Checkbutton Listbox Scrollbar Clipboard Menu Selection Dialog Menubutton Text Entry Message Tk Focus Option Tkwait Frame Optionmenu Toplevel Grab Pack Winfo Grid Palette Wm
Giving a detailed account of each of these module would be impractical here. We will just present some of the basic functions in the module Tk. Note that for most other modules information can be found in the Tcl man page of their name.