[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques Garrigue <garrigue@k...> |
| Subject: | Re: [Caml-list] lablGtk - newbie question |
From: Andrew Lawson <andrew@absentis.com>
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
object
method winMain = winMain
method butNew = butNew
initializer
winMain#connect#destroy ~callback:Main.quit;
winMain#show ()
end
Andrew
--
Andrew Lawson
andrew@absentis.com
Swindon, Wilts, Uk
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr