view pyntnclick/widgets/imagebutton.py @ 670:fe7023750b20 pyntnclick

Add convert_color function
author Stefano Rivera <stefano@rivera.za.net>
date Sun, 12 Feb 2012 18:00:18 +0200
parents fdc63049b08c
children f67bc162d69e
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

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