From 263891a98255b05c2246a7f5662db1dbcd63341b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 30 Sep 2023 12:30:32 +0800 Subject: [PATCH] Enhance | Theme --- Difficult_Rocket/gui/widget/theme/__init__.py | 17 ++++++++++++++++- Difficult_Rocket/gui/widget/theme/button.py | 13 +++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Difficult_Rocket/gui/widget/theme/__init__.py b/Difficult_Rocket/gui/widget/theme/__init__.py index 16a66ac..7d83603 100644 --- a/Difficult_Rocket/gui/widget/theme/__init__.py +++ b/Difficult_Rocket/gui/widget/theme/__init__.py @@ -4,7 +4,9 @@ # All rights reserved # ------------------------------- -from typing import Optional, Tuple +from typing import Optional, Tuple, TYPE_CHECKING + +from pyglet.graphics import Batch, Group class BaseTheme(dict): @@ -19,6 +21,19 @@ class BaseTheme(dict): if hasattr(self, k): setattr(self, k, v) + if TYPE_CHECKING: + def init(self, + batch: Batch, + group: Group, + **kwargs) -> None: + """ + Init theme + :param batch: batch + :param group: group + :param kwargs: options + :return: None + """ + class FontTheme(BaseTheme): """ diff --git a/Difficult_Rocket/gui/widget/theme/button.py b/Difficult_Rocket/gui/widget/theme/button.py index df9252a..43450b9 100644 --- a/Difficult_Rocket/gui/widget/theme/button.py +++ b/Difficult_Rocket/gui/widget/theme/button.py @@ -23,6 +23,18 @@ class ButtonBaseTheme(BaseTheme): """ theme_name = 'Button Base Theme' + def init(self, batch: Batch, group: Group, **kwargs) -> None: + """ + Init theme + :param batch: batch + :param group: group + :param kwargs: options + :return: None + """ + self.batch = batch + self.group = group + self.font_theme = FontTheme(**kwargs) + class BlockTheme(ButtonBaseTheme): """ @@ -34,3 +46,4 @@ class BlockTheme(ButtonBaseTheme): hit_color: _RGBA = (15, 135, 250, 255) font_theme: FontTheme = FontTheme() +