X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fwidgets%2Ftext.py;h=587cb3c675cbb03f3395f3a90a9fa6befc41a5ea;hb=cf09c0ae37a8fa9be5d2ac5134c316682e97f95f;hp=6862b968907ec7132a15bc1a01f509e63d446e45;hpb=84c542f883e16a7f40c70e8a7096b92c063a0e7f;p=naja.git diff --git a/naja/widgets/text.py b/naja/widgets/text.py index 6862b96..587cb3c 100644 --- a/naja/widgets/text.py +++ b/naja/widgets/text.py @@ -132,6 +132,7 @@ class TextBoxWidget(TextWidget): self.border_colour = convert_colour(kwargs.pop('border_colour', PALETTE.BLACK)) self.box_width = kwargs.pop('box_width', 0) + self.centre = kwargs.pop('centre', False) super(TextBoxWidget, self).__init__(*args, **kwargs) @@ -226,6 +227,10 @@ class TextBoxWidget(TextWidget): x, y = self.padding, self.padding for line_surface in rendered_lines: + if self.centre and self.box_width: + x = (width - line_surface.get_rect().width) / 2 + x += self.padding + print x, width, line_surface.get_rect().width self.surface.blit(line_surface, (x, y)) y += line_surface.get_rect().height for pos, img in image_map.items():