5709cec6ba8817caffd3b92171311c37573ecbfa
[naja.git] / naja / widgets / image_box.py
1 """Widget to draw an image"""
2
3 from naja.resources import resources
4 from naja.resources.mutators import EIGHT_BIT
5 from naja.widgets.base import Widget
6
7
8 class ImageBox(Widget):
9     """Widget which holds an image."""
10
11     def __init__(self, pos, image, transforms=(EIGHT_BIT,)):
12         super(ImageBox, self).__init__(pos)
13         self.image = image
14         self.transforms = transforms
15
16     def prepare(self):
17         self.surface = resources.get_image(
18             self.image, transforms=self.transforms)
19         self.size = self.surface.get_rect().size
20
21     def draw(self, surface):
22         surface.blit(self.surface, self.rect)