Repository: MyreMylar/pygame_gui (python)

Issue:
UITextEntryLine acceps a Tuple in relative_rect but crashes since its expecting a pygame.Rect
UITextEntryLine acceps a Tuple in relative_rect but crashes since its expecting a pygame.Rect by calling its .size attribute.
```py
AttributeError: 'Tuple' object has no attribute 'size'
```
Steps to reproduce the behaviour:
1. Pass a Tuple in the relative_rect attribute of pygame_gui.elements.UITextEntryLine.

The element should handle correctly the data type of relative_rect and not try to get its .size attribute since it is not a pygame.Rect.

 - OS: Linux Mint 21.2 x86_64
 - Pygame GUI version e.g. 0.6.9
 - Pygame version: 2.4.1



Pull request description:
Move call to rect.size to after rect is created.
fixes #547

Patch:
diff --git a/pygame_gui/core/ui_element.py b/pygame_gui/core/ui_element.py
index 5f24382..8a27777 100644
--- a/pygame_gui/core/ui_element.py
+++ b/pygame_gui/core/ui_element.py
@@ -62,12 +62,12 @@ class UIElement(GUISprite, IUIElementInterface):
         super().__init__(self.ui_manager.get_sprite_group())
 
         self.minimum_dimensions = (-1, -1)
-        relative_rect.size = self._get_clamped_to_minimum_dimensions(relative_rect.size)
 
         if isinstance(relative_rect, pygame.Rect):
             self.relative_rect = relative_rect.copy()
         else:
             self.relative_rect = pygame.Rect(relative_rect)
+        self.relative_rect.size = self._get_clamped_to_minimum_dimensions(self.relative_rect.size)
         self.rect = self.relative_rect.copy()
 
         self.dynamic_width = True if self.relative_rect.width == -1 else False


Test patch:
diff --git a/tests/test_core/test_ui_element.py b/tests/test_core/test_ui_element.py
index 148bf2f..01f1bcb 100644
--- a/tests/test_core/test_ui_element.py
+++ b/tests/test_core/test_ui_element.py
@@ -22,6 +22,12 @@ class TestUIElement:
                   starting_height=0,
                   layer_thickness=1)
 
+        UIElement(relative_rect=(0, 0, 50, 50),
+                  manager=None,
+                  container=None,
+                  starting_height=0,
+                  layer_thickness=1)
+
         set_default_manager(None)
 
         with pytest.raises(ValueError, match="Need to create at least one UIManager to create UIElements"):