From: Maxence Guesdon <max@sbuilders.com>
To: Andrew Lawson <andrew@absentis.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] lablGtk - newbie question
Date: Sat, 06 Oct 2001 21:36:49 +0200 [thread overview]
Message-ID: <3BBF5D51.15425010@sbuilders.com> (raw)
In-Reply-To: <20011006153439.A882@alba.sw>
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
next prev parent reply other threads:[~2001-10-08 9:36 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 [this message]
2001-10-06 22:50 ` Jacques Garrigue
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=3BBF5D51.15425010@sbuilders.com \
--to=max@sbuilders.com \
--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