Skip to content

Commit 32ad4c9

Browse files
committed
Add package and class metadata to icon enums
Updated CupertinoIcons and Icons classes to include package_name and class_name metadata via IconData's __init_subclass__ method. This change enables better identification and organization of icon sets within the Flet framework.
1 parent 9d9d3e4 commit 32ad4c9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_icons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
__all__ = ["CupertinoIcons"]
1414

1515

16-
class CupertinoIcons(IconData):
16+
class CupertinoIcons(IconData, package_name="flet", class_name="CupertinoIcons"):
1717
ADD = 0x20000
1818
ADD_CIRCLED = 0x20001
1919
ADD_CIRCLED_SOLID = 0x20002

sdk/python/packages/flet/src/flet/controls/icon_data.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ class IconData(IntEnum):
3030
across multiple icon sets.
3131
"""
3232

33+
def __new__(cls, value):
34+
obj = int.__new__(cls, value)
35+
obj._value_ = value
36+
return obj
37+
38+
@classmethod
39+
def __init_subclass__(cls, **kwargs):
40+
cls._package_name = kwargs.pop("package_name", "")
41+
cls._class_name = kwargs.pop("class_name", "")
42+
super().__init_subclass__(**kwargs)
43+
3344
@classmethod
3445
def random(
3546
cls: type[T],

sdk/python/packages/flet/src/flet/controls/material/icons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
__all__ = ["Icons"]
1414

1515

16-
class Icons(IconData):
16+
class Icons(IconData, package_name="flet", class_name="Icons"):
1717
ABC = 0x10000
1818
ABC_OUTLINED = 0x10001
1919
ABC_ROUNDED = 0x10002

0 commit comments

Comments
 (0)