* problem with gbutton
@ 2007-11-02 22:48 Angela Zhu
2007-11-02 23:47 ` [Caml-list] " Julien Moutinho
0 siblings, 1 reply; 5+ messages in thread
From: Angela Zhu @ 2007-11-02 22:48 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 297 bytes --]
Hi,
Can anyone give me an example how to set a GButton.button to be
insensitive or not according to a boolean value "isActive"?
--
Thanks,
Angela Zhu
------------------------------------------
Dept. of CS, Rice University
http://www.cs.rice.edu/~yz2/
------------------------------------------
[-- Attachment #2: Type: text/html, Size: 397 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] problem with gbutton
2007-11-02 22:48 problem with gbutton Angela Zhu
@ 2007-11-02 23:47 ` Julien Moutinho
2007-11-03 3:20 ` Angela Zhu
0 siblings, 1 reply; 5+ messages in thread
From: Julien Moutinho @ 2007-11-02 23:47 UTC (permalink / raw)
To: caml-list
On Fri, Nov 02, 2007 at 05:48:01PM -0500, Angela Zhu wrote:
> Can anyone give me an example how to set a GButton.button to be
> insensitive or not according to a boolean value "isActive"?
The method #misc#set_sensitive, used by a few examples
in the sources of LablGTK, and documented here:
http://plus.kaist.ac.kr/~shoh/ocaml/lablgtk2/lablgtk-2.4.0/doc/html/GObj.misc_ops.html#METHODset_sensitive
may do the job:
% cat test.ml
let _ =
let window = GWindow.window ()
~show: true in
let button = GButton.button ()
~label: "hello"
~packing: window#add in
let isActive = false in
button#misc#set_sensitive isActive;
ignore (window#connect#destroy
~callback: GMain.quit);
GMain.main ()
% ocamlc -o test -I +lablgtk2 lablgtk.cma gtkInit.cmo test.ml
% ./test
HTH,
Julien.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] problem with gbutton
2007-11-02 23:47 ` [Caml-list] " Julien Moutinho
@ 2007-11-03 3:20 ` Angela Zhu
2007-11-03 4:02 ` Julien Moutinho
0 siblings, 1 reply; 5+ messages in thread
From: Angela Zhu @ 2007-11-03 3:20 UTC (permalink / raw)
To: Julien Moutinho, caml-list
[-- Attachment #1: Type: text/plain, Size: 1679 bytes --]
I also want to add
GMain.Idle.add ~callback:(fun () -> true);
But I keep getting:
***********
Expecting function has type ?prio:int -> (unit -> bool) -> Glib.Idle.id
This argument cannot be applied with label ~callback
Any idea?
Thanks,
Angela
On 11/2/07, Julien Moutinho <julien.moutinho@gmail.com> wrote:
>
> On Fri, Nov 02, 2007 at 05:48:01PM -0500, Angela Zhu wrote:
> > Can anyone give me an example how to set a GButton.button to be
> > insensitive or not according to a boolean value "isActive"?
>
> The method #misc#set_sensitive, used by a few examples
> in the sources of LablGTK, and documented here:
>
> http://plus.kaist.ac.kr/~shoh/ocaml/lablgtk2/lablgtk-2.4.0/doc/html/GObj.misc_ops.html#METHODset_sensitive
> may do the job:
>
> % cat test.ml
> let _ =
> let window = GWindow.window ()
> ~show: true in
> let button = GButton.button ()
> ~label: "hello"
> ~packing: window#add in
> let isActive = false in
> button#misc#set_sensitive isActive;
> ignore (window#connect#destroy
> ~callback: GMain.quit);
> GMain.main ()
>
> % ocamlc -o test -I +lablgtk2 lablgtk.cma gtkInit.cmo test.ml
> % ./test
>
> HTH,
> Julien.
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
Regards,
Angela Zhu
------------------------------------------
Dept. of CS, Rice University
http://www.cs.rice.edu/~yz2/
------------------------------------------
[-- Attachment #2: Type: text/html, Size: 2888 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] problem with gbutton
2007-11-03 3:20 ` Angela Zhu
@ 2007-11-03 4:02 ` Julien Moutinho
2007-11-03 4:17 ` Angela Zhu
0 siblings, 1 reply; 5+ messages in thread
From: Julien Moutinho @ 2007-11-03 4:02 UTC (permalink / raw)
To: Angela Zhu; +Cc: caml-list
On Fri, Nov 02, 2007 at 10:20:24PM -0500, Angela Zhu wrote:
> I also want to add
>
> GMain.Idle.add ~callback:(fun () -> true);
>
> But I keep getting:
>
> ***********
> Expecting function has type ?prio:int -> (unit -> bool) -> Glib.Idle.id
> This argument cannot be applied with label ~callback
>
> Any idea?
As said by the error message, the signature of GMain.Idle.add is:
?prio:int -> (* an optional argument: the priority *)
(unit -> bool) -> (* an anonymous argument: the callback *)
Glib.Idle.id (* the returned value: an identifier *)
Here no argument of GMain.Idle.add has a label named "callback",
hence the error you get.
Instead do the following:
let id = GMain.Idle.add (fun _ -> true) in
Also, there is a manual chapter on labels:
http://caml.inria.fr/pub/docs/manual-ocaml/manual006.html
And by the way, do not forget that there is a mailing list
dedicated to LablGTK:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk
HTH.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] problem with gbutton
2007-11-03 4:02 ` Julien Moutinho
@ 2007-11-03 4:17 ` Angela Zhu
0 siblings, 0 replies; 5+ messages in thread
From: Angela Zhu @ 2007-11-03 4:17 UTC (permalink / raw)
To: Julien Moutinho, caml-list
[-- Attachment #1: Type: text/plain, Size: 1304 bytes --]
It works.
Thanks!
-Angela
On 11/2/07, Julien Moutinho <julien.moutinho@gmail.com> wrote:
>
> On Fri, Nov 02, 2007 at 10:20:24PM -0500, Angela Zhu wrote:
> > I also want to add
> >
> > GMain.Idle.add ~callback:(fun () -> true);
> >
> > But I keep getting:
> >
> > ***********
> > Expecting function has type ?prio:int -> (unit -> bool) -> Glib.Idle.id
> > This argument cannot be applied with label ~callback
> >
> > Any idea?
> As said by the error message, the signature of GMain.Idle.add is:
> ?prio:int -> (* an optional argument: the priority *)
> (unit -> bool) -> (* an anonymous argument: the callback *)
> Glib.Idle.id (* the returned value: an identifier *)
> Here no argument of GMain.Idle.add has a label named "callback",
> hence the error you get.
>
> Instead do the following:
> let id = GMain.Idle.add (fun _ -> true) in
>
> Also, there is a manual chapter on labels:
> http://caml.inria.fr/pub/docs/manual-ocaml/manual006.html
>
> And by the way, do not forget that there is a mailing list
> dedicated to LablGTK:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk
>
> HTH.
>
>
--
Regards,
Angela Zhu
------------------------------------------
Dept. of CS, Rice University
http://www.cs.rice.edu/~yz2/
------------------------------------------
[-- Attachment #2: Type: text/html, Size: 2168 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-11-03 4:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-02 22:48 problem with gbutton Angela Zhu
2007-11-02 23:47 ` [Caml-list] " Julien Moutinho
2007-11-03 3:20 ` Angela Zhu
2007-11-03 4:02 ` Julien Moutinho
2007-11-03 4:17 ` Angela Zhu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox