From db521a6a47acd150c806acb2f44b1d47df7e2f8e Mon Sep 17 00:00:00 2001 From: anish-work Date: Thu, 18 Jul 2024 03:17:26 +0530 Subject: [PATCH] code editor: label prop --- gooey_ui/components/__init__.py | 8 +++++++- recipes/Functions.py | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gooey_ui/components/__init__.py b/gooey_ui/components/__init__.py index 3ef59011c..63d5b8cbf 100644 --- a/gooey_ui/components/__init__.py +++ b/gooey_ui/components/__init__.py @@ -379,17 +379,23 @@ def text_area( def code_editor( value: str = "", key: str = None, + label: str = None, + label_visibility: LabelVisibility = "visible", **props, ) -> typing.Any: value = str(state.session_state.setdefault(key, value) or "") - return state.RenderTreeNode( + if label_visibility != "visible": + label = None + state.RenderTreeNode( name="code-editor", props=dict( name=key, defaultValue=value, + label=dedent(label), **props, ), ).mount() + return value or "" def nrows_for_text( diff --git a/recipes/Functions.py b/recipes/Functions.py index 723aef00b..4850214ef 100644 --- a/recipes/Functions.py +++ b/recipes/Functions.py @@ -75,8 +75,12 @@ def run_v2( response.error = data.get("error") def render_form_v2(self): - st.caption("##### " + field_title_desc(self.RequestModel, "code")) - st.code_editor(key="code", language="javascript", height=300) + st.code_editor( + label="##### " + field_title_desc(self.RequestModel, "code"), + key="code", + language="javascript", + height=300, + ) def render_variables(self): variables_input(template_keys=["code"], allow_add=True)