An error in making button labels I don't understand

Nicolas FRANCOIS <[email protected]> Wed, 18 Feb 2015 16:00:42 +0100
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
--MP_/mjKtIoWZaYO+KfEHA6g8qUV
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi.

I'd like to show a bridge hand in a window. This is the code for my
class "affichage_main" (in joined file "visu_une_main.ml").

Problem appears here :

  initializer
    for i = 0 to 3 do
      for j = 0 to 9 do
	nom_carte.(i).(j) <- GMisc.label ~width:8 ~height:10 ();
	if j = 0
	then ignore (nom_carte.(i).(j)#set_text (Glib.Utf8.from_unichar
  (9824+i))); let une_carte = GButton.button ~relief:`NONE
	  ~packing:(grille#attach ~top:i ~left:j ~expand:`BOTH) () in
	let une_boite = GPack.hbox ~packing:une_carte#add () in
	  ignore (une_boite#add (nom_carte.(i).(j)));
          *******************************************
This gives the error : 
Error: This expression has type GMisc.label
       but an expression was expected of type GObj.widget
       The second object type has no method angle

I saw a similar example in
http://plus.kaist.ac.kr/~shoh/ocaml/lablgtk2/lablgtk2-tutorial/c669.html#SEC-NORMALBUTTONS

Can someone tell me what I did wrong ?

If you need any complementary explanation on the code, please ask. I
know it's not easy to read others code, even if it is well written,
which is definitely not one of my strong qualities :-(

\bye


-- 

Nicolas FRANCOIS                      |  /\ 
http://nicolas.francois.free.fr       | |__|
				      X--/\\
We are the Micro$oft.		        _\_V
Resistance is futile.		    
You will be assimilated.         darthvader penguin
--MP_/mjKtIoWZaYO+KfEHA6g8qUV
Content-Type: text/x-ocaml
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=visu_une_main.ml

open Definition
open Etat
open GMain

class affichage_main jo et ?packing ?show () =
  let grille_cartes = GPack.table ~rows:4 ~columns:10 ~homogeneous:true
    ~row_spacings:5 ~col_spacings:5 ~border_width:0 ~show:false () in
object
  val joueur = jo
  val etat = et
  val mutable grille = grille_cartes
  val mutable disponible = false
  val mutable nom_carte =
    Array.make_matrix 4 10 (GMisc.label ~width:8 ~height:10 ())

  method dispo = disponible <- true
  method non_dispo = disponible <- false

  method mise_a_jour =
    if disponible
    then
      let m = cartes_joueur_to_string etat.donne joueur in
      for i = 0 to 3 do
	let n = String.length m.(i) in
	  for j = 1 to n do
	    ignore (nom_carte.(i).(j)#set_text (String.sub m.(i) (j-1) 1))
	  done;
	  for j = n + 1 to 9 do
	    ignore (nom_carte.(i).(j)#set_text "")
	  done
      done
    
  initializer
    for i = 0 to 3 do
      for j = 0 to 9 do
	nom_carte.(i).(j) <- GMisc.label ~width:8 ~height:10 ();
	if j = 0
	then ignore (nom_carte.(i).(j)#set_text (Glib.Utf8.from_unichar (9824+i)));
	let une_carte = GButton.button ~relief:`NONE
	  ~packing:(grille#attach ~top:i ~left:j ~expand:`BOTH) () in
	let une_boite = GPack.hbox ~packing:une_carte#add () in
	  ignore (une_boite#add (nom_carte.(i).(j)));
      done
    done;
    ignore (GObj.pack_return grille ~packing ~show)
end
   

--MP_/mjKtIoWZaYO+KfEHA6g8qUV
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Lablgtk-list mailing list
[email protected]
https://lists.ocamlcore.org/cgi-bin/listinfo/lablgtk-list

--MP_/mjKtIoWZaYO+KfEHA6g8qUV--