Vertically centre the bits box.
[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, eight_bit=True, transforms=()):
12         super(ImageBox, self).__init__(pos)
13         self.image = image
14         if eight_bit:
15             transforms = (EIGHT_BIT,) + transforms
16         self.transforms = transforms
17
18     def prepare(self):
19         self.surface = resources.get_image(
20             self.image, transforms=self.transforms)
21         self.size = self.surface.get_rect().size
22
23     def draw(self, surface):
24         surface.blit(self.surface, self.rect)