caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: andrew@absentis.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] lablGtk - newbie question
Date: Sun, 07 Oct 2001 07:50:54 +0900	[thread overview]
Message-ID: <20011007075054U.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <20011006153439.A882@alba.sw>

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


      parent reply	other threads:[~2001-10-06 22:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-06 14:34 Andrew Lawson
2001-10-06 19:36 ` Maxence Guesdon
2001-10-06 22:50 ` Jacques Garrigue [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011007075054U.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=andrew@absentis.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).