caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* LablGTK Reading Properties
@ 2008-02-05 16:39 Gregory Malecha
  2008-02-06  8:57 ` [Caml-list] " Olivier Andrieu
  0 siblings, 1 reply; 5+ messages in thread
From: Gregory Malecha @ 2008-02-05 16:39 UTC (permalink / raw)
  To: caml-list

Hi,

I've been working on some code with GnomeCanvas and I'm having 
difficulty reading properties off of objects. For example, I've created 
a polygon and I want to read the points from it, but I always get back 
None. Here's my current code:

let points item =
  let prop = {Gobject.name = "points";
          Gobject.conv = GnomeCanvas.Conv.path_def} in
  let x = Gobject.get prop item in
  match x with
    None -> print_string "NONE!\n"; [] (* I always end up in this case *)
  | Some ary ->
      print_string "SOME!\n";
      let ary = GnomeCanvas.Conv.get_points ary in
      Array.to_list ary

My creation code looks like this:

let drawSourcePort group (x, y) dir =
  let lst =
    match dir with
      East ->
    let cX,cY   = x +. 5., y in
    let p1X,p1Y = x, y +. 7.5 in
    let p2X,p2Y = x, y -. 7.5 in
    [cX;cY; p1X;p1Y; p2X;p2Y]
    | West ->
    let cX,cY   = x -. 5., y in
    let p1X,p1Y = x, y +. 7.5 in
    let p2X,p2Y = x, y -. 7.5 in
    [cX;cY; p1X;p1Y; p2X;p2Y]
    | North ->
    let cX,cY   = x, y -. 5. in
    let p1X,p1Y = x +. 7.5, y in
    let p2X,p2Y = x -. 7.5, y in
    [cX;cY; p1X;p1Y; p2X;p2Y]
    | South ->
    let cX,cY   = x, y +. 5. in
    let p1X,p1Y = x +. 7.5, y in
    let p2X,p2Y = x -. 7.5, y in
    [cX;cY; p1X;p1Y; p2X;p2Y]
  in
  let ary = Array.of_list lst in
  GnoCanvas.polygon
    ~points:ary
    ~fill_color:"black"
    group
;;

I've also tried with lines and that fails as well. Does anyone know if 
there is anything special that I have to do in order to be able to read 
properties or why I keep getting null?

Thanks.

-- 
gregory malecha
wiess college
computer science
219.510.3400


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-02-06 22:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-05 16:39 LablGTK Reading Properties Gregory Malecha
2008-02-06  8:57 ` [Caml-list] " Olivier Andrieu
2008-02-06 17:06   ` Gregory Malecha
2008-02-06 19:07     ` Gregory Malecha
2008-02-06 22:12       ` Olivier Andrieu

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).