view pyntnclick/widgets/imagebutton.py @ 807:642564a3bedf pyntnclick

Pretty load and save buttons (placed arbitrarily)
author Stefano Rivera <stefano@rivera.za.net>
date Sun, 27 Jan 2013 16:19:19 +0200
parents bcc9277a23e6
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)