changeset 41:3f44c30a1c39

Correct Text placement
author Stefano Rivera <stefano@rivera.za.net>
date Sun, 11 Sep 2011 15:08:16 +0200
parents 967762f042f8
children 8521c142cd43
files mamba/habitats/mainmenu.py mamba/widgets/base.py mamba/widgets/text.py
diffstat 3 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mamba/habitats/mainmenu.py	Sun Sep 11 15:06:07 2011 +0200
+++ b/mamba/habitats/mainmenu.py	Sun Sep 11 15:08:16 2011 +0200
@@ -8,4 +8,4 @@
 
     def __init__(self):
         super(MainMenu, self).__init__()
-        self.container.add(TextWidget((20, 20), "Hello", color='white'))
+        self.container.add(TextWidget((100, 100), "Hello", color='white'))
--- a/mamba/widgets/base.py	Sun Sep 11 15:06:07 2011 +0200
+++ b/mamba/widgets/base.py	Sun Sep 11 15:08:16 2011 +0200
@@ -5,7 +5,8 @@
 
     def __init__(self, rect):
         if not isinstance(rect, pygame.Rect):
-            rect = pygame.Rect(rect[0], rect[1], 0, 0)
+            rect = pygame.Rect(rect, (0, 0))
+        self.rect = rect
 
     def event(self, event):
         "Override me"
--- a/mamba/widgets/text.py	Sun Sep 11 15:06:07 2011 +0200
+++ b/mamba/widgets/text.py	Sun Sep 11 15:08:16 2011 +0200
@@ -23,7 +23,7 @@
         if not isinstance(self.color, pygame.Color):
             self.color = pygame.Color(self.color)
         self.surface = self.font.render(self.text, True, self.color)
-        self.rect = self.surface.get_rect()
+        self.rect.width, self.rect.height = self.surface.get_rect().size
 
     def draw(self, surface):
         surface.blit(self.surface, self.rect)