view pyntnclick/widgets/imagebutton.py @ 803:bcc9277a23e6 pyntnclick

Refactor widget positioning API. Remove unused widgets
author Stefano Rivera <stefano@rivera.za.net>
date Sun, 27 Jan 2013 14:52:16 +0200
parents f67bc162d69e
children 3a875256f795
line wrap: on
line source

from pyntnclick.widgets.base import Button


class ImageButtonWidget(Button):
    """An image that is also a button. Whatever next?"""

    def __init__(self, pos, gd, image, size=None):
        super(ImageButtonWidget, self).__init__(pos, gd, size)
        if not size:
            self.rect.size = image.get_rect().size
        self.image = image
        self.visible = True

    def draw(self, surface):
        self.disabled = not self.visible
        if self.visible:
            surface.blit(self.image, self.rect)