view pyntnclick/widgets/imagebutton.py @ 784:29c5badeef98 pyntnclick

Use getdefaultlocale, with a envvar list, so that it'll take LANGUAGE first, over LANG
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 26 Jan 2013 19:31:03 +0200
parents f67bc162d69e
children bcc9277a23e6
line wrap: on
line source

import pygame

from pyntnclick.widgets.base import Button


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

    def __init__(self, rect, gd, image):
        if not isinstance(rect, pygame.Rect):
            rect = pygame.Rect(rect, image.get_size())
        super(ImageButtonWidget, self).__init__(rect, gd)
        self.image = image
        self.visible = True

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