Forráskód Böngészése

Detect indexed property as callable (#1842)

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Fred Lefévère-Laoide 7 hónapja
szülő
commit
4006c0b58c

+ 5 - 1
taipy/gui/builder/_api_generator.py

@@ -139,5 +139,9 @@ class _ElementApiGenerator(object, metaclass=_Singleton):
         return type(
             classname,
             (ElementBaseClass,),
-            {"_ELEMENT_NAME": element_name, "_DEFAULT_PROPERTY": default_property, "_TYPES": properties},
+            {
+                "_ELEMENT_NAME": element_name,
+                "_DEFAULT_PROPERTY": default_property,
+                "_TYPES": {f"{parts[0]}__" if len(parts := k.split("[")) > 1 else k: v for k, v in properties.items()},
+            },
         )

+ 3 - 1
taipy/gui/builder/_element.py

@@ -89,7 +89,9 @@ class _Element(ABC):
         return key
 
     def _is_callable(self, name: str):
-        return "callable" in self._TYPES.get(name, "").lower()
+        return (
+            "callable" in self._TYPES.get(f"{parts[0]}__" if len(parts := name.split("__")) > 1 else name, "").lower()
+        )
 
     def _parse_property(self, key: str, value: t.Any) -> t.Any:
         if isinstance(value, (str, dict, Iterable)):

+ 4 - 4
taipy/gui/viselements.json

@@ -788,22 +788,22 @@
                     },
                     {
                         "name": "style[<i>column_name</i>]",
-                        "type": "str",
+                        "type": "Union[str, Callable]",
                         "doc": "Allows the styling of table cells.<br/>See <a href=\"#dynamic-styling\">below</a> for details."
                     },
                     {
                         "name": "tooltip",
-                        "type": "str",
+                        "type": "Union[str, Callable]",
                         "doc": "The name of the function that must return a tooltip text for a cell.<br/>See <a href=\"#cell-tooltips\">below</a> for details."
                     },
                     {
                         "name": "tooltip[<i>column_name</i>]",
-                        "type": "str",
+                        "type": "Union[str, Callable]",
                         "doc": "The name of the function that must return a tooltip text for a cell.<br/>See <a href=\"#cell-tooltips\">below</a> for details."
                     },
                     {
                         "name": "format_fn[<i>column_name</i>]",
-                        "type": "str",
+                        "type": "Union[str, Callable]",
                         "doc": "TODO: The name of the function that must return a formatted value for a cell.<br/>See <a href=\"#cell-formats\">below</a> for details."
                     },
                     {