Allow supplying and image to image button.
[tabakrolletjie.git] / tabakrolletjie / widgets.py
index f34fa35fccc0427477107fae9677b4be91d1cea0..72d726f1d21cfc7ed3d1a53235002a8689561ea5 100644 (file)
@@ -6,6 +6,7 @@ import pygame.locals as pgl
 
 from .loader import loader
 from .constants import FONTS
+from .transforms import NullTransform
 
 
 class Button(object):
@@ -64,7 +65,10 @@ class TextButton(Button):
 class ImageButton(Button):
 
     def __init__(self, *imgparts, **kwargs):
-        self._img = loader.load_image(*imgparts)
+        transform = kwargs.pop("transform", NullTransform())
+        self._img = kwargs.pop("image", None)
+        if self._img is None:
+            self._img = loader.load_image(*imgparts, transform=transform)
         name = kwargs.get('name')
         pos = kwargs.get('pos')
         padding = kwargs.get('padding', 0)