Exemplo n.º 1
0
 def draw(self, dc):
     dc.SetFont(cache.get_font(self.font))
     lines = self.get_lines(dc)
     lines = lines[self.line_offset:]
     padding, _ = dc.GetTextExtent(' ')
     y = 0
     for line in lines:
         tw, th = dc.GetTextExtent(line)
         if y + th > self.height:
             break
         if self.alignment == LEFT:
             x = padding
         elif self.alignment == RIGHT:
             x = self.width - tw - padding
         else:
             x = self.width / 2 - tw / 2
         self.draw_text(dc, line, x, y)
         y += th
Exemplo n.º 2
0
 def get_lines(self, dc=None):
     dc = dc or get_dc()
     dc.SetFont(cache.get_font(self.font))
     lines = word_wrap(dc, self.width, self.label)
     lines = [line or ' ' for line in lines]
     return lines