comparison gamelib/gui_base.py @ 70:442a1bf9b14e

fucking pep8
author Rizmari Versfeld <rizziepit@gmail.com>
date Tue, 08 May 2012 23:10:10 +0200
parents 626b1eaec13c
children 20b01d100ff5
comparison
equal deleted inserted replaced
69:626b1eaec13c 70:442a1bf9b14e
1 import pygame 1 import pygame
2 from pygame.locals import SRCALPHA
2 from pygame import Surface, Rect 3 from pygame import Surface, Rect
3 from pygame.font import Font 4 from pygame.font import Font
4 5
5 from gamelib import data 6 from gamelib import data
6 7
155 class TextButton(Button): 156 class TextButton(Button):
156 157
157 def __init__(self, rect, normal_drawable, down_drawable, text, font, 158 def __init__(self, rect, normal_drawable, down_drawable, text, font,
158 shadow): 159 shadow):
159 super(TextButton, self).__init__(rect, normal_drawable, down_drawable) 160 super(TextButton, self).__init__(rect, normal_drawable, down_drawable)
160 self.surface = Surface((rect[2], rect[3]), pygame.SRCALPHA) 161 self.surface = Surface((rect[2], rect[3]), SRCALPHA)
161 self.text = text 162 self.text = text
162 self.font = font 163 self.font = font
163 self.shadow = shadow 164 self.shadow = shadow
164 self._draw_text() 165 self._draw_text()
165 166
167 self.font.set_bold(True) 168 self.font.set_bold(True)
168 self.text_surface = self.font.render(self.text, True, (0, 0, 0)) 169 self.text_surface = self.font.render(self.text, True, (0, 0, 0))
169 size = self.font.size(self.text) 170 size = self.font.size(self.text)
170 if self.shadow: 171 if self.shadow:
171 s = self.font.render(self.text, True, (128, 128, 128)) 172 s = self.font.render(self.text, True, (128, 128, 128))
172 temp_surface = Surface((s.get_width() + 2, s.get_width() + 2), pygame.SRCALPHA) 173 temp_surface = Surface((s.get_width() + 2, s.get_width() + 2), SRCALPHA)
173 temp_surface.fill((255, 255, 255, 0)) 174 temp_surface.fill((255, 255, 255, 0))
174 temp_surface.blit(s, (2, 2)) 175 temp_surface.blit(s, (2, 2))
175 temp_surface.blit(self.text_surface, (0, 0)) 176 temp_surface.blit(self.text_surface, (0, 0))
176 self.text_surface = temp_surface 177 self.text_surface = temp_surface
177 size = [s + 2 for s in size] 178 size = [s + 2 for s in size]