From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA27952; Mon, 8 Oct 2001 11:36:59 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA27925 for caml-list@pauillac.inria.fr; Mon, 8 Oct 2001 11:36:59 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA03109 for ; Sat, 6 Oct 2001 19:39:51 +0200 (MET DST) Received: from postfix2-1.free.fr (postfix2-1.free.fr [213.228.0.9]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f96HdpD13195 for ; Sat, 6 Oct 2001 19:39:51 +0200 (MET DST) Received: from sbuilders.com (unknown [213.228.2.14]) by postfix2-1.free.fr (Postfix) with ESMTP id 187AB2CD; Sat, 6 Oct 2001 19:39:50 +0200 (CEST) Message-ID: <3BBF5D51.15425010@sbuilders.com> Date: Sat, 06 Oct 2001 21:36:49 +0200 From: Maxence Guesdon Reply-To: max@sbuilders.com X-Mailer: Mozilla 4.77 [fr] (X11; U; Linux 2.4.3-20mdk i686) X-Accept-Language: fr, en MIME-Version: 1.0 To: Andrew Lawson Cc: caml-list@inria.fr Subject: Re: [Caml-list] lablGtk - newbie question References: <20011006153439.A882@alba.sw> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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