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 AAA07648; Sun, 7 Oct 2001 00:51:08 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 AAA07642 for ; Sun, 7 Oct 2001 00:51:07 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f96Mp0D14706 for ; Sun, 7 Oct 2001 00:51:05 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id HAA18655; Sun, 7 Oct 2001 07:50:54 +0900 (JST) To: andrew@absentis.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] lablGtk - newbie question In-Reply-To: <20011006153439.A882@alba.sw> References: <20011006153439.A882@alba.sw> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20011007075054U.garrigue@kurims.kyoto-u.ac.jp> Date: Sun, 07 Oct 2001 07:50:54 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 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