Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/widgets/text.py

    r237 r196  
     1import pygame
     2
    13from nagslang.constants import FONT, FONT_SIZE
    24from nagslang.widgets.base import Widget
    3 import pygame
    4 
    55from nagslang.utils import convert_colour
    66from nagslang.resources import resources
     
    3232
    3333
    34 class MultiLineWidget(TextWidget):
    35 
    36     def prepare(self):
    37         self.font = resources.get_font(self.fontname, self.fontsize)
    38         surfaces = []
    39         height = 0
    40         width = 0
    41         for line in self.text.split('\n'):
    42             surface = self.font.render(line, True, self.colour)
    43             width = max(width, surface.get_rect().width)
    44             height += surface.get_rect().height
    45             surfaces.append(surface)
    46         self.surface = pygame.surface.Surface((width, height))
    47         self.surface.fill(pygame.Color('white'))
    48         y = 0
    49         for surface in surfaces:
    50             self.surface.blit(surface, (0, y))
    51             y += surface.get_rect().height
    52 
    53 
    5434class LabelWidget(TextWidget):
    5535    def __init__(self, *args, **kwargs):
Note: See TracChangeset for help on using the changeset viewer.