comparison gamelib/hand.py @ 36:31a431f795e1

Add a hand button placeholder
author Neil Muller <neil@dip.sun.ac.za>
date Sun, 22 Aug 2010 20:25:13 +0200
parents
children 79062a225703
comparison
equal deleted inserted replaced
35:ebc76bc0c067 36:31a431f795e1
1 # Button for the hand image
2
3 from albow.controls import ImageButton
4 from albow.resource import get_image
5 from albow.utils import frame_rect
6 from pygame.color import Color
7
8 class HandButton(ImageButton):
9 """The fancy hand button for the widget"""
10
11 sel_colour = Color('red')
12 sel_width = 2
13
14 def __init__(self, action):
15 # FIXME: Yes, please.
16 this_image = get_image('items', 'square.png')
17 ImageButton.__init__(self, image=this_image, action=action)
18 self.selected = False # Flag if we're selected
19
20 def draw(self, surface):
21 """Draw the widget"""
22 print 'drawing widget', self.selected
23 ImageButton.draw(self, surface)
24 if self.selected:
25 rect = surface.get_rect().inflate(-self.sel_width, -self.sel_width)
26 frame_rect(surface, self.sel_colour, rect, self.sel_width)
27
28 def toggle_selected(self):
29 self.selected = not self.selected
30
31 def unselect(self):
32 self.selected = False
33