class Label(Widget): def __init__(self, parent, **kwargs): super().__init__(parent) self.rendered_text = MultilineText(self.screen, **kwargs) self.padding = kwargs.get("padding", [0, 0, 0, 0]) self.text_width, self.text_height = max(line.size_list[-1] for line in self.rendered_text.final_lines), self.rendered_text.height_size_list[-1] self.rect = Rect(0, 0, kwargs.get("width", self.text_width + self.padding[0] + self.padding[2]), kwargs.get("height", self.text_height + self.padding[1] + self.padding[3])) def resize(self, **kwargs): super().resize(**kwargs) self.rendered_text.resize(self.rect.size) def calculate_pos(self): self.rendered_text.rect.topleft = self.rect.topleft def update_screen(self, screen): self.screen = screen self.rendered_text.screen = screen def draw(self): self.rendered_text.draw()
def __init__(self, parent, **kwargs): super().__init__(parent) self.rendered_text = MultilineText(self.screen, **kwargs) self.padding = kwargs.get("padding", [0, 0, 0, 0]) self.text_width, self.text_height = max(line.size_list[-1] for line in self.rendered_text.final_lines), self.rendered_text.height_size_list[-1] self.rect = Rect(0, 0, kwargs.get("width", self.text_width + self.padding[0] + self.padding[2]), kwargs.get("height", self.text_height + self.padding[1] + self.padding[3]))