Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamus_ <mail2samus@gmail.com>2010-03-21 07:51:56 (GMT)
committer Samus_ <mail2samus@gmail.com>2010-03-21 07:51:56 (GMT)
commit21a3ed4983c9c0fc12f5dbef66cf012f3e648cb2 (patch)
treeef474db45d0871623b11b946fdafe69ef266d4a9
parentf15aa8633f4970007f344b94586ddce5ebf08fc7 (diff)
moving image loading to constructor
-rwxr-xr-xfracciones.activity/gtkcake.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/fracciones.activity/gtkcake.py b/fracciones.activity/gtkcake.py
index 931cf25..7f77d98 100755
--- a/fracciones.activity/gtkcake.py
+++ b/fracciones.activity/gtkcake.py
@@ -31,6 +31,10 @@ class Cake(gtk.DrawingArea):
self.subdivisions = subdivisions
self.selected = subdivisions * [0]
+ # Carga imagenes
+ self.image_bg = cairo.ImageSurface.create_from_png(os.path.join("data", "bg.png"))
+ self.image_fg = cairo.ImageSurface.create_from_png(os.path.join("data", "fg.png"))
+
def expose(self, widget, event):
"""Manejador del evento expose_event"""
@@ -90,10 +94,6 @@ class Cake(gtk.DrawingArea):
context.paint()
- # Carga imagenes
- image_bg = cairo.ImageSurface.create_from_png(os.path.join("data", "bg.png"))
- image_fg = cairo.ImageSurface.create_from_png(os.path.join("data", "fg.png"))
-
# Escala la imagen al tamaƱo de la superficie
rect = self.get_allocation()
context.save()
@@ -103,11 +103,11 @@ class Cake(gtk.DrawingArea):
)
# Dibuja el fondo
- context.set_source_surface(image_bg, 0, 0)
+ context.set_source_surface(self.image_bg, 0, 0)
context.paint()
# Dibuja el frente
- mask_image(context, self.selected, image_fg)
+ mask_image(context, self.selected, self.image_fg)
# Dibuja la rejilla
draw_grid(context, self.subdivisions)