Module Tkthread

module Tkthread: sig .. end
Helper functions for using LablTk with threads. To use, add tkthread.cmo or tkthread.cmx to your command line

val start : unit -> Thread.t
Start the main loop in a new GUI thread. Do not use recursively.
val thread_main : unit -> unit
The actual function executed in the GUI thread
val top : Widget.toplevel Widget.widget
The toplevel widget (an alias of Widget.default_toplevel)

Jobs are needed for Windows, as you cannot do GUI work from another thread. This is apparently true on OSX/Aqua too. And even using X11 some calls need to come from the main thread. The basic idea is to either use async (if you don't need a result) or sync whenever you call a Tk related function from another thread (for instance with the threaded toplevel). With sync, beware of deadlocks!
val async : ('a -> unit) -> 'a -> unit
Add an asynchronous job (to do in the GUI thread)
val sync : ('a -> 'b) -> 'a -> 'b
Add a synchronous job (to do in the GUI thread). Raise Failure "Tkthread.sync" if there is no such thread.
val gui_safe : unit -> bool
Whether the current thread is the GUI thread. Note that when using X11 it is generally safe to call most Tk functions from other threads too.
val running : unit -> bool
Whether a GUI thread is running