Mercurial > pyntnclick
annotate pyntnclick/widgets/imagebutton.py @ 639:fdc63049b08c pyntnclick
Add game_description to the widgets,, since it looks a useful thing to do
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sun, 12 Feb 2012 01:31:14 +0200 |
parents | 08647ef4d324 |
children | f67bc162d69e |
rev | line source |
---|---|
604
08647ef4d324
ImageButtons have sizes.
Jeremy Thurgood <firxen@gmail.com>
parents:
601
diff
changeset
|
1 import pygame |
08647ef4d324
ImageButtons have sizes.
Jeremy Thurgood <firxen@gmail.com>
parents:
601
diff
changeset
|
2 |
601 | 3 from pyntnclick.widgets.base import Button |
4 | |
5 | |
6 class ImageButtonWidget(Button): | |
7 """An image that is also a button. Whatever next?""" | |
8 | |
639
fdc63049b08c
Add game_description to the widgets,, since it looks a useful thing to do
Neil Muller <neil@dip.sun.ac.za>
parents:
604
diff
changeset
|
9 def __init__(self, rect, gd, image): |
604
08647ef4d324
ImageButtons have sizes.
Jeremy Thurgood <firxen@gmail.com>
parents:
601
diff
changeset
|
10 if not isinstance(rect, pygame.Rect): |
08647ef4d324
ImageButtons have sizes.
Jeremy Thurgood <firxen@gmail.com>
parents:
601
diff
changeset
|
11 rect = pygame.Rect(rect, image.get_size()) |
639
fdc63049b08c
Add game_description to the widgets,, since it looks a useful thing to do
Neil Muller <neil@dip.sun.ac.za>
parents:
604
diff
changeset
|
12 super(ImageButtonWidget, self).__init__(rect, gd) |
601 | 13 self.image = image |
14 | |
15 def draw(self, surface): | |
16 surface.blit(self.image, self.rect) |