Mercurial > boomslang
comparison 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 |
comparison
equal
deleted
inserted
replaced
664:d1c1253fcd77 | 665:12149ea1c18e |
---|---|
84 height = text_rect.height + self.padding * 2 | 84 height = text_rect.height + self.padding * 2 |
85 self.rect.width = max(self.rect.width, width) | 85 self.rect.width = max(self.rect.width, width) |
86 self.rect.height = max(self.rect.height, height) | 86 self.rect.height = max(self.rect.height, height) |
87 self.surface = pygame.Surface(self.rect.size, SRCALPHA) | 87 self.surface = pygame.Surface(self.rect.size, SRCALPHA) |
88 self.surface.fill(0) | 88 self.surface.fill(0) |
89 self.surface.blit(text, text.get_rect().move(self.padding, | 89 offset = ( |
90 self.padding)) | 90 (self.rect.width - width) / 2 + self.padding, |
91 pygame.draw.rect(self.surface, color, self.surface.get_rect(), | 91 (self.rect.height - height) / 2 + self.padding) |
92 self.border) | 92 self.surface.blit(text, text.get_rect().move(offset)) |
93 if self.border: | |
94 pygame.draw.rect(self.surface, color, self.surface.get_rect(), | |
95 self.border) | |
93 | 96 |
94 def draw(self, surface): | 97 def draw(self, surface): |
95 super(TextButton, self).draw(surface) | 98 super(TextButton, self).draw(surface) |