Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
LablTk problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: wester@i...
Subject: LablTk problem

I want to make a little Tk application. I have a main frame, a 
menu frame with a menu button, a menu and a menu command.
Within the menu frame there is also a button. Besides this I have 
a canvas. The button works, when pressing it, the application exits.
But the menu command doesn't react at all. I also tried the
program in the otherlibs\labltk\example directory. Here the menu 
command doesn't work too. I run an ocamltop with libltk.cma linked in
under WindowsNT. 

I would be very appreciative for help.

With kind regards.

Rolf Wester


#directory "h:\programme\ocaml30\lib\labltk";;
#labels true;;

let mainWindow () =
  let top = Tk.openTk() in

  let menuFrame   = Frame.create top ~width: 20 ~height: 20 ~background: `Red in
	Tk.pack ~side: `Top  ~fill: `X   [menuFrame];

  let fileButton  = Menubutton.create menuFrame ~text:"File"  ~borderwidth:3  ~relief: `Groove in 
	Tk.pack ~side: `Left [fileButton];
  let fileMenu    = Menu.create fileButton in
    Menu.add_command  fileMenu ~label:"Exit..." ~command: (fun () -> closeTk ();); 

  let exitButton = Button.create  menuFrame ~text: "Exit"  ~borderwidth:3 ~relief: `Ridge in
	Tk.pack ~side: `Right [exitButton];
	bind  ~events:[`ButtonPress] ~action: (fun ev -> closeTk ();) exitButton; 

  let canvas      = Canvas.create top ~width: 600 ~height: 400 ~background: `White in
	Tk.pack [canvas];

let canvas = mainWindow ();;
Tk.mainLoop ();;

Rolf Wester