[pygtk] Copy and restore GtkDrawingArea contents?
Steven I Usdansky
usdanskys at rocketmail.com
Wed Jun 13 10:14:41 WST 2012
I'm trying to shave some time off the draw event by saving the image the
first time it's drawn and then restoring it when requested based on the
value of self.flag as shown in the simplified example below. Is there
an easy way to do this?
def draw_event(self, da, ctx=None):
""" Draw the cross section """
print "self.flag = ",self.flag
if self.flag==0:
# this code takes a long time to execute
ctx.set_source_rgb(0.4,0.9,0.4)
ctx.paint()
ctx.set_source_rgb(0,0,0)
ctx.move_to(390,90)
ctx.line_to(500,200)
ctx.stroke()
# save_the_image
else:
if self.flag%2!=0:
ctx.set_source_rgba(1,0.5,0.5,0.25)
ctx.rectangle(400,100,100,100)
ctx.fill()
else:
# restore_the_image
More information about the pygtk
mailing list