Mercurial > pyntnclick
diff pyntnclick/widgets/text.py @ 665:12149ea1c18e pyntnclick
Menu button.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 12 Feb 2012 17:06:45 +0200 |
parents | 1faced4e343a |
children | de3f6ad0da9d |
line wrap: on
line diff
--- a/pyntnclick/widgets/text.py Sun Feb 12 16:53:40 2012 +0200 +++ b/pyntnclick/widgets/text.py Sun Feb 12 17:06:45 2012 +0200 @@ -86,10 +86,13 @@ self.rect.height = max(self.rect.height, height) self.surface = pygame.Surface(self.rect.size, SRCALPHA) self.surface.fill(0) - self.surface.blit(text, text.get_rect().move(self.padding, - self.padding)) - pygame.draw.rect(self.surface, color, self.surface.get_rect(), - self.border) + offset = ( + (self.rect.width - width) / 2 + self.padding, + (self.rect.height - height) / 2 + self.padding) + self.surface.blit(text, text.get_rect().move(offset)) + if self.border: + pygame.draw.rect(self.surface, color, self.surface.get_rect(), + self.border) def draw(self, surface): super(TextButton, self).draw(surface)