self.tw = TextWidget((10, 10), 'Haai', colour=(255, 255, 255))
def render(self, surface):
- self.tw.draw(surface)
+ self.tw.render(surface)
def handle_event(self, ev):
pass
def rect(self):
return pygame.Rect(self.pos, self.size)
+ def render(self, surface):
+ if not self._prepared:
+ self.prepare()
+ self._prepared = True
+ self.draw(surface)
+
def draw(self, surface):
raise NotImplemented()
def prepare(self):
- if not self._prepared:
- self._prepare()
- self._prepared = True
-
- def _prepare(self):
raise NotImplemented()
self.fontsize = fontsize or FONT_SIZE
self.colour = colour or (0, 0, 0)
- def _prepare(self):
+ def prepare(self):
self.font = resources.get_font(self.fontname, self.fontsize)
self.surface = self.font.render(self.text, True, self.colour)
self.size = self.surface.get_rect().size
def draw(self, surface):
- self.prepare()
surface.blit(self.surface, self.rect)