[
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: | 2001-10-08 (09:36) |
From: | Maxence Guesdon <max@s...> |
Subject: | Re: [Caml-list] lablGtk - newbie question |
Andrew Lawson a écrit : > > 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; > > class mainWindow () = > object (self) > val winMain = GWindow.window ~title:"Cadb" ~border_width:10 > i ~width:400 ~height:400 () > val butNew = GButton.button ~label:"New" () > initializer > winMain#add butNew; (* This would seem the obvious thing to > do but it doesn't work *) > winMain#connect#destroy ~callback:Main.quit; > winMain#show () > end > > 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? > to pack the button in the window : winMain#add butNew#coerce; BTW, a cool way to make the same but using the ~packing parameters : class mainWindow () = let winMain = GWindow.window ~title:"Cadb" ~border_width:10 ... in let _ = winMain#connect#destroy ~callback:Main.quit in let butNew = GButton.button ~label:"New" ~packing: winMain#add () in object (self) initializer winMain#show () end -- Maxence Guesdon ------------------- 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