Enhance | Theme

This commit is contained in:
shenjack 2023-09-30 12:30:32 +08:00
parent 3f097c3ed5
commit 263891a982
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 29 additions and 1 deletions

View File

@ -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):
"""

View File

@ -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()