PyGObject and Cairo



Hello,

I am currently attempting to port labyrinth, a mindmap application
written in PyGTK and cairo, to PyGObject and cairo. Labyrinth uses a
custom widget subclassed from Gtk.DrawingArea() drawn with cairo. I am
having difficulty discovering how to hook things up properly in the
brave new world of gobject-introspection!

The relevant PyGTK functions looked like this

    def expose (self, widget, event):
        '''Expose event.  Calls the draw function'''
        context = self.window.cairo_create ()
        self.draw (event, context)
        return False

    def draw (self, event, context):
        '''Draw the map and all the associated thoughts'''
        area = event.area
        context.rectangle (area.x, area.y, area.width, area.height)
        context.clip ()
        context.set_source_rgb (1.0,1.0,1.0)
        context.move_to (area.x, area.y)
        context.paint ()
        context.set_source_rgb (0.0,0.0,0.0)
	...

I changed the expose function to

    def expose (self, widget, event):
        '''Expose event.  Calls the draw function'''
        context = self.get_property('window').cairo_create()
        self.draw(event, context)
        return False

but when I run this code I get

  File "/home/blang/code/absinthe/ABSINTHE/gtkui/editor/mmaparea.py",
line 770, in expose
    self.draw(event, context)
  File "../mmaparea.py", line 775, in draw
    area = event.area
AttributeError: 'cairo.Context' object has no attribute 'area'

Any assistance appreciated!

Brent



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