At the top: import cairo Then later on: def OnDraw(self, widget, event): """ Fires off the drawing operation. Parameters: widget -- reserved for GTK callbacks, don't use it explicitly. event -- reserved for GTK callbacks, don't use it explicitly. """ if self.savedLine == None: self.DrawLine() d = widget.window gc = d.new_gc() # Get a cairo surface for this drawing op context = widget.window.cairo_create() # Give it our waveform image as a source context.set_source_surface(self.savedLine, 0,0) # Blit our waveform across context.paint() ## # redraw area from saved gtk.gdk.Image ## d.draw_image(gc, self.savedLine, ## event.area.x, event.area.y, ## event.area.x, event.area.y, ## event.area.width, event.area.height) # Draw play cursor position # Set the color: col = gc.get_colormap().alloc_color("#FF0000") gc.set_foreground(col) # And draw: x = int(round((self.project.transport.position - self.project.viewStart) * self.project.viewScale)) d.draw_line(gc, x, 0, x, self.get_allocation().height) #_____________________________________________________________________ def DrawLine(self): """ Draws the timeline and saves it to memory Must be called initially and to redraw the timeline after moving the project start. """ rect = self.get_allocation() self.savedLine = cairo.ImageSurface(cairo.FORMAT_ARGB32, rect.width, rect.height) context = cairo.Context(self.savedLine) context.set_line_width(2) context.set_antialias(cairo.ANTIALIAS_SUBPIXEL) # Draw white background context.rectangle(0, 0, rect.width, rect.height) context.set_source_rgb(1,1,1) context.fill()