|
|
| "ocaml_beginners"::[] Ocaml-TK
intro/tutorial? |
  Germany |
2007-06-12 12:13:55 |
|
Hello,
is there somewhere an introduction to
OCaml/Tk?
In the OCaml manual there are not all bindings
to the widgest explained.
TIA,
Oliver
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
Ocaml-TK intro/tutorial? |
  Germany |
2007-06-12 12:19:50 |
|
Am Tue, 12 Jun 2007 19:13:55 +0200
schrieb Oliver Bandel < oliver%40first.in-berlin.de">oliver first.in-berlin.de>:
> Hello,
>
> is there somewhere an introduction to
> OCaml/Tk?
>
> In the OCaml manual there are not all bindings
> to the widgest explained.
>
I had the same problem the solution is a good bokk about tk and
looking at ocaml-tk examples...
Michael
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
Ocaml-TK intro/tutorial? |
  Germany |
2007-06-12 12:47:08 |
|
Zitat von micha < micha-1%40fantasymail.de">micha-1 fantasymail.de>:
> Am Tue, 12 Jun 2007 19:13:55 +0200
> schrieb Oliver Bandel < oliver%40first.in-berlin.de">oliver first.in-berlin.de>:
>
> > Hello,
> >
> > is there somewhere an introduction to
> > OCaml/Tk?
> >
> > In the OCaml manual there are not all bindings
> > to the widgest explained.
> >
>
> I had the same problem the solution is a good bokk about tk and
> looking at ocaml-tk examples...
>
> Michael
>
OK, well, so after this bad bnews from you I had an idea... 
I did the following:
$ ocaml -I +labltk labltk.cma| tee COPY
Heheh, then I typed:
module T = Camltk;;
And then I quitted the toplevel.
heheh, now I have the signature of the Tk-module in a textfile..
and just used caml2html to create a html of it. 
heheh. This is at least the signature. 
I had done Tcl/Tk many years ago, so I know the
rudiments of the Tk-stuff. Tcl sucks, but with OCaml it's OK
to work with Tk, I think.
Ciao,
Oliver
__._,_.___
.
__,_._,___
|
| Camltk.pack to pack a widget into
another widget (Re:
"ocaml_beginners"::[] Ocaml-TK
intro/tutoria |
  Germany |
2007-06-12 14:35:26 |
|
__,_._,___
|
| Re: Camltk.pack to pack a widget into
another widget (Re:
"ocaml_beginners"::[] Ocaml-TK
intro/tut |
  Germany |
2007-06-12 15:49:58 |
|
This does not what I expected:
=================================================================
open Camltk
let _ =
let mainwin = openTk() in
let f1 = Frame.create mainwin [] in
let b1 = Button.create mainwin [Text "Quitter 1"; Command closeTk] in
let b2 = Button.create mainwin [Text "Quitter 2"; Command closeTk] in
let b3 = Button.create mainwin [Text "Quitter 3"; Command closeTk] in
let b4 = Button.create mainwin [Text "Quitter 4"; Command closeTk] in
let b5 = Button.create f1 [Text "Quitter 5"; Command closeTk] in
let b6 = Button.create f1 [Text "Quitter 6"; Command closeTk] in
pack [ f1 ] [Side Side_Left];
pack [ b1; b2 ] [Side Side_Bottom];
pack [ b3; b4 ] [Side Side_Top];
mainLoop()
=================================================================
And I didn't got grid running.
maybe I misunderstand the type-definitions ?!
A simple example could help enormously...
Ciao,
Oliver
__._,_.___
.
__,_._,___
|
| Re: Camltk.pack to pack a widget into
another widget (Re:
"ocaml_beginners"::[] Ocaml-TK
intro/tut |
  United States |
2007-06-12 15:47:42 |
|
On Tue, 12 Jun 2007, Oliver Bandel wrote:
> This does not what I expected:
>
> =================================================================
> open Camltk
>
> let _ =
>
> let mainwin = openTk() in
> let f1 = Frame.create mainwin [] in
> let b1 = Button.create mainwin [Text "Quitter 1"; Command closeTk] in
> let b2 = Button.create mainwin [Text "Quitter 2"; Command closeTk] in
> let b3 = Button.create mainwin [Text "Quitter 3"; Command closeTk] in
> let b4 = Button.create mainwin [Text "Quitter 4"; Command closeTk] in
> let b5 = Button.create f1 [Text "Quitter 5"; Command closeTk] in
> let b6 = Button.create f1 [Text "Quitter 6"; Command closeTk] in
> pack [ f1 ] [Side Side_Left];
> pack [ b1; b2 ] [Side Side_Bottom];
> pack [ b3; b4 ] [Side Side_Top];
> mainLoop()
> =================================================================
Before you pack "f1", you'll want to do something like this:
pack [ b5; b6 ] [Side Side_Top];
Usually, you want to pack starting with the innermost widgets and working
your way out to the toplevel window.
It might be helpful to read some introductory material on Tcl/Tk.
Dave
__._,_.___
.
__,_._,___
|
| Re: Camltk.pack to pack a widget into
another widget (Re:
"ocaml_beginners"::[] Ocaml-TK
intro/tut |
  Germany |
2007-06-12 16:15:16 |
|
Zitat von Dave Benjamin < ramen%40ramenfest.com">ramen ramenfest.com>:
> On Tue, 12 Jun 2007, Oliver Bandel wrote:
>
> > This does not what I expected:
> >
> > =================================================================
> > open Camltk
> >
> > let _ =
> >
> > let mainwin = openTk() in
> > let f1 = Frame.create mainwin [] in
> > let b1 = Button.create mainwin [Text "Quitter 1"; Command closeTk] in
> > let b2 = Button.create mainwin [Text "Quitter 2"; Command closeTk] in
> > let b3 = Button.create mainwin [Text "Quitter 3"; Command closeTk] in
> > let b4 = Button.create mainwin [Text "Quitter 4"; Command closeTk] in
> > let b5 = Button.create f1 [Text "Quitter 5"; Command closeTk] in
> > let b6 = Button.create f1 [Text "Quitter 6"; Command closeTk] in
> > pack [ f1 ] [Side Side_Left];
> > pack [ b1; b2 ] [Side Side_Bottom];
> > pack [ b3; b4 ] [Side Side_Top];
> > mainLoop()
> > =================================================================
>
> Before you pack "f1", you'll want to do something like this:
>
> pack [ b5; b6 ] [Side Side_Top];
>
> Usually, you want to pack starting with the innermost widgets and working
> your way out to the toplevel window.
>
> It might be helpful to read some introductory material on Tcl/Tk
Yes, maybe it's too long ago that I used Tk.
I've forgotten the details. :(
Ciao,
Oliver
__._,_.___
.
__,_._,___
|
| Re: Camltk.pack to pack a widget into
another widget (Re:
"ocaml_beginners"::[] Ocaml-TK
intro/tut |
  Germany |
2007-06-12 16:29:36 |
|
Am Tue, 12 Jun 2007 21:35:26 +0200
schrieb Oliver Bandel < oliver%40first.in-berlin.de">oliver first.in-berlin.de>:
> Do you have an example to pack a widget inside
> a widget that is not the mainwidget?
>
> How to use pack (or other packers) to put
> for example a button inside a frame (not main-widget)?
>
this works for me (using findlib in the toplevel):
#use "topfind";;
#require "labltk";;
open Tk;;
let main = openTk();;
let f1 = Frame.create main ;;
let b1 = Button.create ~text:"Quitter1" ~command:(fun () ->
print_endline "hi 1") main ;;
let b2 = Button.create ~text:"Quitter2" ~command:(fun () ->
print_endline "hi 2") f1 ;;
let b3 = Button.create ~text:"Quitter3" ~command:(fun () ->
print_endline "hi 3") f1 ;;
pack [b2;b3] ~side: `Left ~expand:true ~fill:`X ;;
pack [f1] ~side:`Top ~expand:true ~fill:`Both ;;
pack [b1] ~side:`Bottom ~expand:true ~fill:`X;;
mainLoop();;
this display a window with three buttons...
here is a link:
http://www.cs.uiuc.edu/class/sp07/cs421/resources/labltk/
cheers,
Michael
__._,_.___
.
__,_._,___
|
| Re: Camltk.pack to pack a widget into
another widget (Re:
"ocaml_beginners"::[] Ocaml-TK
intro/tut |
  Germany |
2007-06-12 16:51:01 |
|
Zitat von micha < micha-1%40fantasymail.de">micha-1 fantasymail.de>:
> Am Tue, 12 Jun 2007 21:35:26 +0200
> schrieb Oliver Bandel < oliver%40first.in-berlin.de">oliver first.in-berlin.de>:
>
> > Do you have an example to pack a widget inside
> > a widget that is not the mainwidget?
> >
> > How to use pack (or other packers) to put
> > for example a button inside a frame (not main-widget)?
> >
>
> this works for me (using findlib in the toplevel):
>
> #use "topfind";;
> #require "labltk";;
>
> open Tk;;
> let main = openTk();;
> let f1 = Frame.create main ;;
> let b1 = Button.create ~text:"Quitter1" ~command:(fun () ->
> print_endline "hi 1") main ;;
> let b2 = Button.create ~text:"Quitter2" ~command:(fun () ->
> print_endline "hi 2") f1 ;;
> let b3 = Button.create ~text:"Quitter3" ~command:(fun () ->
> print_endline "hi 3") f1 ;;
> pack [b2;b3] ~side: `Left ~expand:true ~fill:`X ;;
> pack [f1] ~side:`Top ~expand:true ~fill:`Both ;;
> pack [b1] ~side:`Bottom ~expand:true ~fill:`X;;
> mainLoop();;
>
>
> this display a window with three buttons...
Fine.
A lot of different types ijh there.
I tried this:
let b1 = Button.create mainwin [Height (Pixels 5); Text "Quitter 1"; Command
closeTk] in
and it worked (even if it looked different than expected.
Then I tried this:
let b1 = Button.create mainwin [Height (Millimeters 5.0); Text "Quitter 1";
Command closeTk] in
and got:
Fatal error: exception Protocol.TkError("expected integer but got "5m"")
why this?
In the signature I found:
type units =
CTk.units =
Pixels of int
| Centimeters of float
| Inches of float
| Millimeters of float
| PrinterPoint of float
So, why didn't it worked?!
Ciao,
Oliver
__._,_.___
.
__,_._,___
|
| Re: Camltk.pack to pack a widget into
another widget (Re:
"ocaml_beginners"::[] Ocaml-TK
intro/tut |
  Moldova, Republic of |
2007-06-13 00:24:22 |
|
Shalom, Oliver.
OB> Do you have an example to pack a widget inside
OB> a widget that is not the mainwidget?
If I understood correctly, you should use "coe"
function. For example, see
$camlsrc/otherlibs/labltk/examples_labltk/tetris.ml:
pack [f];
pack [coe c; coe r; coe r'] ~side: `Left ~fill: `Y;
pack [coe nl; coe nc] ~side: `Top;
pack [coe scl; coe sc; coe lnl; coe ln; coe levl;
coe lev; coe newg] ~side: `Top;
--
WBR,
dmitry mailto: gds-mlsts%40moldavcable.com">gds-mlsts moldavcable.com
__._,_.___
.
__,_._,___
|