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
[Caml-list] lablGtk - newbie question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-10-06 (22:51)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] lablGtk - newbie question
From: Andrew Lawson <>
Subject: [Caml-list] lablGtk - newbie question
Date: Sat, 6 Oct 2001 15:34:39 +0100

> Hi all
> 	I've just started learning ocaml and lablGtk. I'm writing a
> small utility and I'm trying to encapsulate the gui in a class, a
> simplified example is below;

> 	Now I have to pack the button into the window, obviously I can't
> do it in the val expression but I can't work out how to do it in the
> initializer. Can someone help?

I suppose your "does not work" comment is about a type error.
You should be more explicit, since GTK misbehaviour is also a frequent
problem :-)
The type problem is solved by
    winMain#add butNew#coerce

On the other hand, using val to define winMain does not allow for the
most natural lablGTK style:

class mainWindow () =
  let winMain = GWindow.window ~title:"Cadb" ~border_width:10
                               ~width:400 ~height:400 () in
  let butNew = GButton.button ~label:"New" ~packing:winMain#add () in
    method winMain = winMain
    method butNew = butNew
      winMain#connect#destroy ~callback:Main.quit;
      winMain#show ()


   Andrew Lawson
Swindon, Wilts, Uk
Bug reports:  FAQ:
To unsubscribe, mail  Archives:
Bug reports:  FAQ:
To unsubscribe, mail  Archives: