<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="ThreadUnix.html"> <link rel="next" href="Unix.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Arg" rel="Chapter" href="Arg.html"> <link title="Arith_status" rel="Chapter" href="Arith_status.html"> <link title="Array" rel="Chapter" href="Array.html"> <link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html"> <link title="Big_int" rel="Chapter" href="Big_int.html"> <link title="Bigarray" rel="Chapter" href="Bigarray.html"> <link title="Buffer" rel="Chapter" href="Buffer.html"> <link title="Callback" rel="Chapter" href="Callback.html"> <link title="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.html"> <link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html"> <link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html"> <link title="Char" rel="Chapter" href="Char.html"> <link title="Complex" rel="Chapter" href="Complex.html"> <link title="Condition" rel="Chapter" href="Condition.html"> <link title="Dbm" rel="Chapter" href="Dbm.html"> <link title="Digest" rel="Chapter" href="Digest.html"> <link title="Dynlink" rel="Chapter" href="Dynlink.html"> <link title="Event" rel="Chapter" href="Event.html"> <link title="Filename" rel="Chapter" href="Filename.html"> <link title="Format" rel="Chapter" href="Format.html"> <link title="Gc" rel="Chapter" href="Gc.html"> <link title="Genlex" rel="Chapter" href="Genlex.html"> <link title="Graphics" rel="Chapter" href="Graphics.html"> <link title="GraphicsX11" rel="Chapter" href="GraphicsX11.html"> <link title="Hashtbl" rel="Chapter" href="Hashtbl.html"> <link title="Int32" rel="Chapter" href="Int32.html"> <link title="Int64" rel="Chapter" href="Int64.html"> <link title="Lazy" rel="Chapter" href="Lazy.html"> <link title="Lexing" rel="Chapter" href="Lexing.html"> <link title="List" rel="Chapter" href="List.html"> <link title="ListLabels" rel="Chapter" href="ListLabels.html"> <link title="Map" rel="Chapter" href="Map.html"> <link title="Marshal" rel="Chapter" href="Marshal.html"> <link title="MoreLabels" rel="Chapter" href="MoreLabels.html"> <link title="Mutex" rel="Chapter" href="Mutex.html"> <link title="Nativeint" rel="Chapter" href="Nativeint.html"> <link title="Num" rel="Chapter" href="Num.html"> <link title="Obj" rel="Chapter" href="Obj.html"> <link title="Oo" rel="Chapter" href="Oo.html"> <link title="Parsing" rel="Chapter" href="Parsing.html"> <link title="Pervasives" rel="Chapter" href="Pervasives.html"> <link title="Printexc" rel="Chapter" href="Printexc.html"> <link title="Printf" rel="Chapter" href="Printf.html"> <link title="Queue" rel="Chapter" href="Queue.html"> <link title="Random" rel="Chapter" href="Random.html"> <link title="Scanf" rel="Chapter" href="Scanf.html"> <link title="Set" rel="Chapter" href="Set.html"> <link title="Sort" rel="Chapter" href="Sort.html"> <link title="Stack" rel="Chapter" href="Stack.html"> <link title="StdLabels" rel="Chapter" href="StdLabels.html"> <link title="Str" rel="Chapter" href="Str.html"> <link title="Stream" rel="Chapter" href="Stream.html"> <link title="String" rel="Chapter" href="String.html"> <link title="StringLabels" rel="Chapter" href="StringLabels.html"> <link title="Sys" rel="Chapter" href="Sys.html"> <link title="Thread" rel="Chapter" href="Thread.html"> <link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html"> <link title="Tk" rel="Chapter" href="Tk.html"> <link title="Unix" rel="Chapter" href="Unix.html"> <link title="UnixLabels" rel="Chapter" href="UnixLabels.html"> <link title="Weak" rel="Chapter" href="Weak.html"><link title="Initialization and termination" rel="Section" href="#6_Initializationandtermination"> <link title="Application wide commands" rel="Section" href="#6_Applicationwidecommands"> <link title="Dimensions" rel="Section" href="#6_Dimensions"> <link title="Widget layout commands" rel="Section" href="#6_Widgetlayoutcommands"> <link title="Event handling" rel="Section" href="#6_Eventhandling"> <title>Tk</title> </head> <body> <div class="navbar"><a href="ThreadUnix.html">Previous</a> <a href="index.html">Up</a> <a href="Unix.html">Next</a> </div> <center><h1>Module <a href="type_Tk.html">Tk</a></h1></center> <br> <pre><span class="keyword">module</span> Tk: <code class="code"><span class="keyword">sig</span></code> <a href="Tk.html">..</a> <code class="code"><span class="keyword">end</span></code></pre>Basic functions and types for LablTk<br> <hr width="100%"> <br> <a name="6_Initializationandtermination"></a> <h6>Initialization and termination</h6><br> <pre><span class="keyword">val</span> <a name="VALopenTk"></a>openTk : <code class="type">?display:string -> ?clas:string -> unit -> Widget.toplevel Widget.widget</code></pre><div class="info"> Initialize LablTk and open a toplevel window. <code class="code">display</code> is described according to the X11 conventions. <code class="code">clas</code> is used for the X11 resource mechanism.<br> </div> <pre><span class="keyword">val</span> <a name="VALmainLoop"></a>mainLoop : <code class="type">unit -> unit</code></pre><div class="info"> Start the main event loop<br> </div> <pre><span class="keyword">val</span> <a name="VALcloseTk"></a>closeTk : <code class="type">unit -> unit</code></pre><div class="info"> Quit the main loop and close all open windows.<br> </div> <pre><span class="keyword">val</span> <a name="VALdestroy"></a>destroy : <code class="type">'a Widget.widget -> unit</code></pre><div class="info"> Destroy an individual widget.<br> </div> <br> <a name="6_Applicationwidecommands"></a> <h6>Application wide commands</h6><br> <pre><span class="keyword">val</span> <a name="VALupdate"></a>update : <code class="type">unit -> unit</code></pre><div class="info"> Synchronize display with internal state.<br> </div> <pre><span class="keyword">val</span> <a name="VALappname_get"></a>appname_get : <code class="type">unit -> string</code></pre><pre><span class="keyword">val</span> <a name="VALappname_set"></a>appname_set : <code class="type">string -> unit</code></pre><div class="info"> Get or set the application name.<br> </div> <br> <a name="6_Dimensions"></a> <h6>Dimensions</h6><br> <pre><span class="keyword">type</span> <a name="TYPEunits"></a><code class="type"></code>units = <code class="type">[ `Cm of float | `In of float | `Mm of float | `Pix of int | `Pt of float ]</code> </pre> <pre><span class="keyword">val</span> <a name="VALpixels"></a>pixels : <code class="type"><a href="Tk.html#TYPEunits">units</a> -> int</code></pre><div class="info"> Converts various on-screen units to pixels, respective to the default display. Available units are pixels, centimeters, inches, millimeters and points<br> </div> <br> <a name="6_Widgetlayoutcommands"></a> <h6>Widget layout commands</h6><br> <pre><span class="keyword">type</span> <a name="TYPEanchor"></a><code class="type"></code>anchor = <code class="type">[ `Center | `E | `N | `Ne | `Nw | `S | `Se | `Sw | `W ]</code> </pre> <pre><span class="keyword">type</span> <a name="TYPEfillMode"></a><code class="type"></code>fillMode = <code class="type">[ `Both | `None | `X | `Y ]</code> </pre> <pre><span class="keyword">type</span> <a name="TYPEside"></a><code class="type"></code>side = <code class="type">[ `Bottom | `Left | `Right | `Top ]</code> </pre> <pre><span class="keyword">val</span> <a name="VALpack"></a>pack : <code class="type">?after:'a Widget.widget -><br> ?anchor:<a href="Tk.html#TYPEanchor">anchor</a> -><br> ?before:'b Widget.widget -><br> ?expand:bool -><br> ?fill:<a href="Tk.html#TYPEfillMode">fillMode</a> -><br> ?inside:'c Widget.widget -><br> ?ipadx:int -><br> ?ipady:int -><br> ?padx:int -> ?pady:int -> ?side:<a href="Tk.html#TYPEside">side</a> -> 'd Widget.widget list -> unit</code></pre><div class="info"> Pack a widget inside its parent, using the standard layout engine.<br> </div> <pre><span class="keyword">val</span> <a name="VALgrid"></a>grid : <code class="type">?column:int -><br> ?columnspan:int -><br> ?inside:'a Widget.widget -><br> ?ipadx:int -><br> ?ipady:int -><br> ?padx:int -><br> ?pady:int -><br> ?row:int -> ?rowspan:int -> ?sticky:string -> 'b Widget.widget list -> unit</code></pre><div class="info"> Pack a widget inside its parent, using the grid layout engine.<br> </div> <pre><span class="keyword">type</span> <a name="TYPEborderMode"></a><code class="type"></code>borderMode = <code class="type">[ `Ignore | `Inside | `Outside ]</code> </pre> <pre><span class="keyword">val</span> <a name="VALplace"></a>place : <code class="type">?anchor:<a href="Tk.html#TYPEanchor">anchor</a> -><br> ?bordermode:<a href="Tk.html#TYPEborderMode">borderMode</a> -><br> ?height:int -><br> ?inside:'a Widget.widget -><br> ?relheight:float -><br> ?relwidth:float -><br> ?relx:float -><br> ?rely:float -> ?width:int -> ?x:int -> ?y:int -> 'b Widget.widget -> unit</code></pre><div class="info"> Pack a widget inside its parent, at absolute coordinates.<br> </div> <pre><span class="keyword">val</span> <a name="VALraise_window"></a>raise_window : <code class="type">?above:'a Widget.widget -> 'b Widget.widget -> unit</code></pre><pre><span class="keyword">val</span> <a name="VALlower_window"></a>lower_window : <code class="type">?below:'a Widget.widget -> 'b Widget.widget -> unit</code></pre><div class="info"> Raise or lower the window associated to a widget.<br> </div> <br> <a name="6_Eventhandling"></a> <h6>Event handling</h6><br> <pre><span class="keyword">type</span> <a name="TYPEmodifier"></a><code class="type"></code>modifier = <code class="type">[ `Alt<br> | `Button1<br> | `Button2<br> | `Button3<br> | `Button4<br> | `Button5<br> | `Control<br> | `Double<br> | `Lock<br> | `Meta<br> | `Mod1<br> | `Mod2<br> | `Mod3<br> | `Mod4<br> | `Mod5<br> | `Shift<br> | `Triple ]</code> </pre> <pre><span class="keyword">type</span> <a name="TYPEevent"></a><code class="type"></code>event = <code class="type">[ `ButtonPress<br> | `ButtonPressDetail of int<br> | `ButtonRelease<br> | `ButtonReleaseDetail of int<br> | `Circulate<br> | `ColorMap<br> | `Configure<br> | `Destroy<br> | `Enter<br> | `Expose<br> | `FocusIn<br> | `FocusOut<br> | `Gravity<br> | `KeyPress<br> | `KeyPressDetail of string<br> | `KeyRelease<br> | `KeyReleaseDetail of string<br> | `Leave<br> | `Map<br> | `Modified of <a href="Tk.html#TYPEmodifier">modifier</a> list * <a href="Tk.html#TYPEevent">event</a><br> | `Motion<br> | `Property<br> | `Reparent<br> | `Unmap<br> | `Visibility ]</code> </pre> <br> An event can be either a basic X event, or modified by a key or mouse modifier.<br> <br><code><span class="keyword">type</span> <a name="TYPEeventInfo"></a><code class="type"></code>eventInfo = {</code><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Above : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_ButtonNumber : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Count : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Detail : <code class="type">string</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Focus : <code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Height : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_KeyCode : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Mode : <code class="type">string</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_OverrideRedirect : <code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Place : <code class="type">string</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_State : <code class="type">string</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Time : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Width : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_MouseX : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_MouseY : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Char : <code class="type">string</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_BorderWidth : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_SendEvent : <code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_KeySymString : <code class="type">string</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_KeySymInt : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_RootWindow : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_SubWindow : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Type : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_Widget : <code class="type">Widget.any Widget.widget</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_RootX : <code class="type">int</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span class="keyword">mutable </span>ev_RootY : <code class="type">int</code>;</code></td> </tr></table> } <br> Event related information accessible in callbacks.<br> <pre><span class="keyword">type</span> <a name="TYPEeventField"></a><code class="type"></code>eventField = <code class="type">[ `Above<br> | `BorderWidth<br> | `ButtonNumber<br> | `Char<br> | `Count<br> | `Detail<br> | `Focus<br> | `Height<br> | `KeyCode<br> | `KeySymInt<br> | `KeySymString<br> | `Mode<br> | `MouseX<br> | `MouseY<br> | `OverrideRedirect<br> | `Place<br> | `RootWindow<br> | `RootX<br> | `RootY<br> | `SendEvent<br> | `State<br> | `SubWindow<br> | `Time<br> | `Type<br> | `Widget<br> | `Width ]</code> </pre> <br> In order to access the above event information, one has to pass a list of required event fields to the <code class="code">bind</code> function.<br> <pre><span class="keyword">val</span> <a name="VALbind"></a>bind : <code class="type">events:<a href="Tk.html#TYPEevent">event</a> list -><br> ?extend:bool -><br> ?breakable:bool -><br> ?fields:<a href="Tk.html#TYPEeventField">eventField</a> list -><br> ?action:(<a href="Tk.html#TYPEeventInfo">eventInfo</a> -> unit) -> 'a Widget.widget -> unit</code></pre><div class="info"> Bind a succession of <code class="code">events</code> on a widget to an <code class="code">action</code>. If <code class="code">extend</code> is true then then binding is added after existing ones, otherwise it replaces them. <code class="code">breakable</code> should be true when <code class="code">break</code> is to be called inside the action. <code class="code">action</code> is called with the <code class="code">fields</code> required set in an <code class="code">eventInfo</code> structure. Other fields should not be accessed. If <code class="code">action</code> is omitted then existing bindings are removed.<br> </div> <pre><span class="keyword">val</span> <a name="VALbind_class"></a>bind_class : <code class="type">events:<a href="Tk.html#TYPEevent">event</a> list -><br> ?extend:bool -><br> ?breakable:bool -><br> ?fields:<a href="Tk.html#TYPEeventField">eventField</a> list -><br> ?action:(<a href="Tk.html#TYPEeventInfo">eventInfo</a> -> unit) -> ?on:'a Widget.widget -> string -> unit</code></pre><div class="info"> Same thing for all widgets of a given class. If a widget is given with label <code class="code">~on:</code>, the binding will be removed as soon as it is destroyed.<br> </div> <pre><span class="keyword">val</span> <a name="VALbind_tag"></a>bind_tag : <code class="type">events:<a href="Tk.html#TYPEevent">event</a> list -><br> ?extend:bool -><br> ?breakable:bool -><br> ?fields:<a href="Tk.html#TYPEeventField">eventField</a> list -><br> ?action:(<a href="Tk.html#TYPEeventInfo">eventInfo</a> -> unit) -> ?on:'a Widget.widget -> string -> unit</code></pre><div class="info"> Same thing for all widgets having a given tag<br> </div> <pre><span class="keyword">val</span> <a name="VALbreak"></a>break : <code class="type">unit -> unit</code></pre><div class="info"> Used inside a bound action, do not call other actions after this one. This is only possible if this action was bound with <code class="code">~breakable:<span class="keyword">true</span></code>.<br> </div> </body></html>