comparison gamelib/state.py @ 79:d7c0a702a0b4

Factor label width setting method out into a custom class (BoomLabel).
author Simon Cross <hodgestar+bzr@gmail.com>
date Mon, 23 Aug 2010 23:09:29 +0200
parents 6bfebfbce42e
children 593bddfacf18
comparison
equal deleted inserted replaced
78:6bfebfbce42e 79:d7c0a702a0b4
1 """Utilities and base classes for dealing with scenes.""" 1 """Utilities and base classes for dealing with scenes."""
2 2
3 from albow.resource import get_image, get_sound 3 from albow.resource import get_image, get_sound
4 from albow.utils import frame_rect 4 from albow.utils import frame_rect
5 from albow.controls import Label 5 from widgets import BoomLabel
6 from pygame.locals import BLEND_ADD 6 from pygame.locals import BLEND_ADD
7 from pygame.rect import Rect 7 from pygame.rect import Rect
8 from pygame.color import Color 8 from pygame.color import Color
9 9
10 import constants 10 import constants
135 del self.things[thing.name] 135 del self.things[thing.name]
136 136
137 def _make_description(self, text): 137 def _make_description(self, text):
138 if text is None: 138 if text is None:
139 return None 139 return None
140 label = Label(text) 140 label = BoomLabel(text)
141 # TODO: create derived label class that does this 141 label.set_margin(5)
142 # manually recalculate size
143 d = 5
144 w, h = label.size
145 label.margin = d
146 label.size = (w+2*d, h+2*d)
147 label.border_width = 1 142 label.border_width = 1
148 label.border_color = (0, 0, 0) 143 label.border_color = (0, 0, 0)
149 label.bg_color = (127, 127, 127) 144 label.bg_color = (127, 127, 127)
150 label.fg_color = (0, 0, 0) 145 label.fg_color = (0, 0, 0)
151 return label 146 return label