view pyntnclick/widgets/imagebutton.py @ 813:3a875256f795 pyntnclick

better visible handling
author Neil Muller <neil@dip.sun.ac.za>
date Sun, 27 Jan 2013 17:33:04 +0200
parents bcc9277a23e6
children
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

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