Skip to content

Instantly share code, notes, and snippets.

@hkoba
Created March 28, 2013 00:25
Show Gist options
  • Save hkoba/5259450 to your computer and use it in GitHub Desktop.
Save hkoba/5259450 to your computer and use it in GitHub Desktop.
How to use [tktable](http://tktable.sourceforge.net/tktable/doc/tkTable.html) from OCaml labltk. (Not yet typesafe)
#directory "+labltk";;
#load "labltk.cma";;
let top = Tk.openTk ()
let rec tcl_eval_str str =
tcl_eval_list (Protocol.splitlist str)
and tcl_eval_list lst =
Protocol.tkEval (list2tkArgs lst)
and list2tkArgs lst =
Array.of_list (List.map (fun i -> Protocol.TkToken i) lst)
;;
let _ = tcl_eval_str "package require Tktable"
let w = Widget.new_atom "table" ~parent:top
let _ = print_endline (Widget.name w)
let _ = tcl_eval_list ["table"; (Widget.name w); "-cache"; "yes"]
let _ = Tk.pack [Tk.coe w]
let _ = Printexc.print Tk.mainLoop ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment