comparison pyntnclick/widgets/imagebutton.py @ 604:08647ef4d324 pyntnclick

ImageButtons have sizes.
author Jeremy Thurgood <firxen@gmail.com>
date Sat, 11 Feb 2012 20:11:58 +0200
parents 0ae62d824d2f
children fdc63049b08c
comparison
equal deleted inserted replaced
603:3ce19d33b51f 604:08647ef4d324
1 import pygame
2
1 from pyntnclick.widgets.base import Button 3 from pyntnclick.widgets.base import Button
2 4
3 5
4 class ImageButtonWidget(Button): 6 class ImageButtonWidget(Button):
5 """An image that is also a button. Whatever next?""" 7 """An image that is also a button. Whatever next?"""
6 8
7 def __init__(self, rect, image): 9 def __init__(self, rect, image):
10 if not isinstance(rect, pygame.Rect):
11 rect = pygame.Rect(rect, image.get_size())
8 super(ImageButtonWidget, self).__init__(rect) 12 super(ImageButtonWidget, self).__init__(rect)
9 self.image = image 13 self.image = image
10 14
11 def draw(self, surface): 15 def draw(self, surface):
12 surface.blit(self.image, self.rect) 16 surface.blit(self.image, self.rect)