Segfault when subclassing ItemModelSimple



I've been trying unsuccessfully to subclass ItemModelSimple in my application. 
But I cannot see what I'm doing wrong. 

I've written the code based on the only piece of documentation available on 
the matter: 
https://bugs.launchpad.net/pygoocanvas/+bug/295952

But I'm still getting a segfault right after calling root.add_child. Here's 
the code: 

#!/usr/bin/python
import gtk
import goocanvas
from util import ValueSymbol
from models import PointModel

class PointModel(goocanvas.ItemModelSimple, goocanvas.ItemModel):
    def __init__(self, point, **props):
        super(PointModel, self).__init__(**props)
        self.point = point

    def do_create_item(self, canvas):
        item = goocanvas.Ellipse(center_x = self.point[0],
                                 center_y = self.point[1])
        item.set_canvas(canvas)
        item.set_model(self)
        return item

w = gtk.Window()
canvas = goocanvas.Canvas()
canvas.set_bounds(0,0,400,400)
canvas.set_size_request(400,400)
w.add(canvas)

p = (200,200)

point_model = PointModel(p)

root = goocanvas.GroupModel()
canvas.set_root_item_model(root)

root.add_child(point_model, -1)

w.show_all()
gtk.main()


Any help would be appreciated!
-- 
  -Andrés


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]