Mercurial > mamba
changeset 156:77ea895e4d37
Transparent widgets
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Tue, 13 Sep 2011 22:42:21 +0200 |
parents | 9afea431af36 |
children | 31881bf8ddda |
files | mamba/widgets/imagebutton.py mamba/widgets/text.py |
diffstat | 2 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mamba/widgets/imagebutton.py Tue Sep 13 22:41:49 2011 +0200 +++ b/mamba/widgets/imagebutton.py Tue Sep 13 22:42:21 2011 +0200 @@ -1,4 +1,5 @@ import pygame +from pygame.locals import SRCALPHA from mamba.constants import COLOR, FONT_SIZE, FOCUS_COLOR from mamba.widgets.base import Button @@ -27,7 +28,8 @@ + 5 + self.padding * 2 self.rect.height = max(text_surface.get_height(), self.image.get_height()) + self.padding * 2 - self.surface = pygame.Surface(self.rect.size) + self.surface = pygame.Surface(self.rect.size, SRCALPHA) + self.surface.fill(0) self.surface.blit(self.image, (self.padding, self.padding)) self.surface.blit(text_surface, (self.image.get_width() + 5 + self.padding, self.padding))
--- a/mamba/widgets/text.py Tue Sep 13 22:41:49 2011 +0200 +++ b/mamba/widgets/text.py Tue Sep 13 22:42:21 2011 +0200 @@ -1,4 +1,5 @@ import pygame +from pygame.constants import SRCALPHA from mamba.constants import COLOR, FONT_SIZE, FOCUS_COLOR from mamba.widgets.base import Widget, Button @@ -52,7 +53,8 @@ self.rect.width = text_rect.width + self.padding * 2 self.rect.height = text_rect.height + self.padding * 2 - self.surface = pygame.Surface(self.rect.size) + 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(),