From 96838bd8688da98f7a47cda6da9dbfc872aaa6f7 Mon Sep 17 00:00:00 2001 From: Dan Lawrence Date: Thu, 19 Dec 2019 15:34:13 +0000 Subject: [PATCH] fixing bugs in text box and text entry line. new bugfix release --- docs/source/conf.py | 4 ++-- pygame_gui/elements/ui_button.py | 4 +--- pygame_gui/elements/ui_text_box.py | 8 ++++++++ pygame_gui/elements/ui_text_entry_line.py | 19 ++++++++++++++++++- setup.py | 2 +- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 86bf23fd..82f6b516 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -32,9 +32,9 @@ author = 'Dan Lawrence' # The short X.Y version -version = '0.4.1' +version = '0.4.2' # The full version, including alpha/beta/rc tags -release = '0.4.1' +release = '0.4.2' # -- General configuration --------------------------------------------------- diff --git a/pygame_gui/elements/ui_button.py b/pygame_gui/elements/ui_button.py index acc11fbe..77e3091d 100644 --- a/pygame_gui/elements/ui_button.py +++ b/pygame_gui/elements/ui_button.py @@ -250,9 +250,7 @@ def update_containing_rect_position(self): Updates the position of this element based on the position of it's container. Usually called when the container has moved. """ - self.rect = pygame.Rect((self.ui_container.rect.x + self.relative_rect.x, - self.ui_container.rect.y + self.relative_rect.y), - self.relative_rect.size) + super().update_containing_rect_position() self.drawable_shape.set_position(self.rect.topleft) diff --git a/pygame_gui/elements/ui_text_box.py b/pygame_gui/elements/ui_text_box.py index 11040033..0e0c0b73 100644 --- a/pygame_gui/elements/ui_text_box.py +++ b/pygame_gui/elements/ui_text_box.py @@ -99,6 +99,14 @@ def __init__(self, html_text: str, self.rebuild_from_changed_theme_data() + def kill(self): + """ + Overrides the standard sprite kill method to also kill any scroll bar belonging to this text box. + """ + if self.scroll_bar is not None: + self.scroll_bar.kill() + super().kill() + def rebuild(self): """ Rebuild whatever needs building. diff --git a/pygame_gui/elements/ui_text_entry_line.py b/pygame_gui/elements/ui_text_entry_line.py index 05a969a7..3f3e4187 100644 --- a/pygame_gui/elements/ui_text_entry_line.py +++ b/pygame_gui/elements/ui_text_entry_line.py @@ -1,7 +1,7 @@ import pygame import re import warnings -from typing import Union, List +from typing import Union, List, Tuple import pygame_gui from pygame_gui.ui_manager import UIManager @@ -152,6 +152,23 @@ def rebuild(self): # setup for drawing self.redraw() + def set_position(self, position: Union[pygame.math.Vector2, Tuple[int, int], Tuple[float, float]]): + """ + Method to directly set the absolute rect position of a text entry line. + + :param position: The new position to set. + """ + super().set_position(position) + self.drawable_shape.set_position(self.rect.topleft) + + def update_containing_rect_position(self): + """ + Updates the position of this element based on the position of it's container. Usually called when the container + has moved. + """ + super().update_containing_rect_position() + self.drawable_shape.set_position(self.rect.topleft) + def set_text_length_limit(self, limit: int): """ Allows a character limit to be set on the text entry element. By default there is no limit on the number diff --git a/setup.py b/setup.py index 77f13a03..585cf73d 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ def _post_install(): setup( cmdclass={'develop': DevelopOnlyInstall}, name='pygame_gui', - version='0.4.1', + version='0.4.2', description='A GUI module for pygame 2', long_description="Helps create GUIs for games made using pygame 2. Features HTML-style text formatting, " "theme files to control the look and a system to manage multiple windows of GUI stuff.",