Add PreRenderedImageBox widget
authorNeil <neil@dip.sun.ac.za>
Sat, 17 May 2014 21:36:15 +0000 (23:36 +0200)
committerNeil <neil@dip.sun.ac.za>
Sat, 17 May 2014 21:37:20 +0000 (23:37 +0200)
naja/widgets/image_box.py

index 32787dfce793d9813a904e899ba55cf81be2c0bd..e9b4bf398d4e941dc731d795338e7e79324ca0b5 100644 (file)
@@ -22,3 +22,18 @@ class ImageBox(Widget):
 
     def draw(self, surface):
         surface.blit(self.surface, self.rect)
+
+
+class PreRenderedImageBox(Widget):
+    """Hold an image given as a surface"""
+
+    def __init__(self, pos, image):
+        super(PreRenderedImageBox, self).__init__(pos)
+        self.surface = image.copy()
+
+    def prepare(self):
+        self.size = self.surface.get_rect().size
+
+    def draw(self, surface):
+        surface.blit(self.surface, self.rect)
+