Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/CMultiLabel.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/CMultiLabel.py')
-rwxr-xr-xsrc/CMultiLabel.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/CMultiLabel.py b/src/CMultiLabel.py
new file mode 100755
index 0000000..3371a7c
--- /dev/null
+++ b/src/CMultiLabel.py
@@ -0,0 +1,44 @@
+import pygame
+
+class CMultiLabel(pygame.sprite.Sprite):
+ """ accepts a list of strings, creates a multi-line
+ label to display text
+ same properties as label except textLines
+ is a list of strings. There is no text
+ property.
+ Set the size manually. Vertical size should be at
+ least 30 pixels per line (with the default font)
+ """
+
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+ self.textLines = ["This", "is", "sample", "text"]
+ #self.font = pygame.font.Font("freesansbold.ttf", 20)
+ #TODO: Esto no debe ir aca. Porque este no anda y el de CSuperSprite si ?
+ #pygame.font.init()
+ #print "CMultilabel"
+ #print pygame.font.get_init()
+ self.font = pygame.font.Font("goodfoot.ttf", 30)
+ self.fgColor = ((0x00, 0x00, 0x00))
+ self.bgColor = ((0xFF, 0xFF, 0xFF))
+ self.center = (100, 100)
+ self.size = (150, 100)
+
+ self.image = pygame.Surface(self.size)
+ self.image.fill(self.bgColor)
+ numLines = len(self.textLines)
+ vSize = self.image.get_height() / numLines
+
+ for lineNum in range(numLines):
+ currentLine = self.textLines[lineNum]
+ fontSurface = self.font.render(currentLine, True, self.fgColor, self.bgColor)
+ #center the text
+ xPos = (self.image.get_width() - fontSurface.get_width())/2
+ yPos = lineNum * vSize
+ self.image.blit(fontSurface, (xPos, yPos))
+
+ self.rect = self.image.get_rect()
+ self.rect.center = self.center
+
+ #def update(self):
+ #print "update de multilabel"