From d86127e820813c6059a8286add92c5ddefb0bf48 Mon Sep 17 00:00:00 2001 From: Vinson Huang Date: Sat, 24 Feb 2024 18:56:02 -0600 Subject: [PATCH] selectbox map implement (#184) --- zt_backend/models/components/selectbox.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/zt_backend/models/components/selectbox.py b/zt_backend/models/components/selectbox.py index 4bb5da77..b7299e6e 100644 --- a/zt_backend/models/components/selectbox.py +++ b/zt_backend/models/components/selectbox.py @@ -33,4 +33,13 @@ def get_value_from_global_state(cls, value, values): return execution_state.component_values[id] # Return the value associated with id in global_state except Exception as e: e - return value # If id doesn't exist in global_state, return the original value \ No newline at end of file + return value # If id doesn't exist in global_state, return the original value + + @classmethod + def from_dict(cls, items_map: dict, id: str, value: Union[str, int, None] = None, label: Optional[str] = None, multiple: Optional[bool] = None, + dense: Optional[bool] = None, outlined: Optional[bool] = None, clearable: Optional[bool] = None, disabled: Optional[bool] = None, + readonly: Optional[bool] = None, color: Optional[str] = None, triggerEvent: str = 'update:modelValue'): + """Creates a SelectBox instance from a dictionary.""" + items = items_map.keys() + return cls(items=items, id=id, value=value, label=label, multiple=multiple, dense=dense, outlined=outlined, clearable=clearable, + disabled=disabled, readonly=readonly, color=color, triggerEvent=triggerEvent) \ No newline at end of file