Mercurial > boomslang
annotate gamelib/hand.py @ 49:8771d545a493
Remove debugging print
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Mon, 23 Aug 2010 11:59:41 +0200 |
parents | 79062a225703 |
children | 4f9d412d83db |
rev | line source |
---|---|
36 | 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): | |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
9 """The fancy hand button for the widget""" |
36 | 10 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
11 sel_colour = Color('red') |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
12 sel_width = 2 |
36 | 13 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
14 def __init__(self, action): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
15 # FIXME: Yes, please. |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
16 this_image = get_image('items', 'square.png') |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
17 ImageButton.__init__(self, image=this_image, action=action) |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
18 self.selected = False # Flag if we're selected |
36 | 19 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
20 def draw(self, surface): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
21 """Draw the widget""" |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
22 ImageButton.draw(self, surface) |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
23 if self.selected: |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
24 rect = surface.get_rect().inflate(-self.sel_width, -self.sel_width) |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
25 frame_rect(surface, self.sel_colour, rect, self.sel_width) |
36 | 26 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
27 def toggle_selected(self): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
28 self.selected = not self.selected |
36 | 29 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
30 def unselect(self): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
31 self.selected = False |
36 | 32 |