Add image button
[tabakrolletjie.git] / tabakrolletjie / widgets.py
index ff854de1f70b140e0e58926a51a8deb2c7a05e05..3f37b52919c15cc28d1fd37e4c5327732c8fab2b 100644 (file)
@@ -57,3 +57,15 @@ class TextButton(Button):
 
     def render(self, surface):
         surface.blit(self._text, self._pos, None)
+
+
+class ImageButton(Button):
+
+    def __init__(self, *imgparts, **kwargs):
+        self._img = loader.load_image(*imgparts)
+        pos = kwargs.get('pos')
+        padding = kwargs.get('padding', 0)
+        super(ImageButton, self).__init__(self._img.get_size(), pos, padding)
+
+    def render(self, surface):
+        surface.blit(self._img, self._pos, None)