From 79565520409685ca644ddc37317e9a7e9369c358 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 6 May 2023 20:51:08 -0400 Subject: [PATCH 1/4] Clarify UIDummy docstring --- arcade/gui/widgets/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arcade/gui/widgets/__init__.py b/arcade/gui/widgets/__init__.py index 90a5ca834..d2e874c53 100644 --- a/arcade/gui/widgets/__init__.py +++ b/arcade/gui/widgets/__init__.py @@ -716,8 +716,14 @@ def on_click(self, event: UIOnClickEvent): class UIDummy(UIInteractiveWidget): """ - Solid color widget, used for testing. - Prints own rect on click. + Solid color widget used for testing & examples + + It should not be subclassed for real-world usage. + + When clicked, it does the following: + + * Outputs its `rect` attribute to the console + * Changes its color to a new, random color :param float x: x coordinate of bottom left :param float y: y coordinate of bottom left From b38363639a5e611e7541b524318026d2d3ec9564 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 6 May 2023 20:53:26 -0400 Subject: [PATCH 2/4] Replace RGB color generation with equivalent Color.random(a=255) call --- arcade/gui/widgets/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arcade/gui/widgets/__init__.py b/arcade/gui/widgets/__init__.py index d2e874c53..f709f8815 100644 --- a/arcade/gui/widgets/__init__.py +++ b/arcade/gui/widgets/__init__.py @@ -28,7 +28,7 @@ from arcade.gui.nine_patch import NinePatchTexture from arcade.gui.property import Property, bind, ListProperty from arcade.gui.surface import Surface -from arcade.types import RGBA255 +from arcade.types import RGBA255, Color if TYPE_CHECKING: from arcade.gui.ui_manager import UIManager @@ -765,7 +765,7 @@ def __init__( def on_click(self, event: UIOnClickEvent): print("UIDummy.rect:", self.rect) - self.color = (randint(0, 255), randint(0, 255), randint(0, 255)) + self.color = Color.random(a=255) def on_update(self, dt): self.border_width = 2 if self.hovered else 0 From eee08e2cee23d9b455b0aeb2b3c9d7818c3aa4f2 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 6 May 2023 20:54:58 -0400 Subject: [PATCH 3/4] Fix PyCharm lint warning by adding UIDummy to __all__ --- arcade/gui/widgets/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/gui/widgets/__init__.py b/arcade/gui/widgets/__init__.py index f709f8815..917616457 100644 --- a/arcade/gui/widgets/__init__.py +++ b/arcade/gui/widgets/__init__.py @@ -33,7 +33,7 @@ if TYPE_CHECKING: from arcade.gui.ui_manager import UIManager -__all__ = ["Surface"] +__all__ = ["Surface", "UIDummy"] class Rect(NamedTuple): From 88fb69970500c2df4ee5e8de0c3507e93eebd76e Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 6 May 2023 21:01:34 -0400 Subject: [PATCH 4/4] Phrasing tweak in UIDummy docstring --- arcade/gui/widgets/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/gui/widgets/__init__.py b/arcade/gui/widgets/__init__.py index 917616457..d34447541 100644 --- a/arcade/gui/widgets/__init__.py +++ b/arcade/gui/widgets/__init__.py @@ -723,7 +723,7 @@ class UIDummy(UIInteractiveWidget): When clicked, it does the following: * Outputs its `rect` attribute to the console - * Changes its color to a new, random color + * Changes its color to a random fully opaque color :param float x: x coordinate of bottom left :param float y: y coordinate of bottom left