1212PANEL_ACCESSOR_KEY  =  "StreamlitPanelValueAccessor" 
1313
1414
15- def  create_streamlit_panel (streamlit_script_path : Path ) ->  StreamlitPanel :
15+ def  create_streamlit_panel (streamlit_script_path : Path ,  panel_id :  str   =   "" ) ->  StreamlitPanel :
1616    """Create a Streamlit panel with the specified script path. 
1717
18-     This function initializes a Streamlit panel using the provided script path. It derives the panel  
19-     ID from the script's path, which it expects to be a valid Streamlit script. For example, if the  
20-     value for streamlit_script_path is "c:/example/some_example.py", then the panel's ID becomes  
21-     "some_example". 
18+     This function initializes a Streamlit panel using the provided script path. By default, it  
19+     derives the panel  ID from the script's path, which it expects to be a valid Streamlit script. 
20+     For example, if the  value for streamlit_script_path is "c:/example/some_example.py", then the 
21+     panel's ID becomes  "some_example". Alternatively, you can specify a custom panel_id . 
2222
2323    Use this function when you want to create a new panel instance to use in a Streamlit 
2424    application. Do not call this function from within a Streamlit script. 
2525
2626    Args: 
2727        streamlit_script_path: The file path of the Streamlit script to be used for the panel. 
28+         panel_id: Optional custom panel ID. If not provided, it will be derived from the script 
29+             path. 
2830
2931    Returns: 
3032        A StreamlitPanel instance initialized with the given panel ID. 
@@ -39,7 +41,9 @@ def create_streamlit_panel(streamlit_script_path: Path) -> StreamlitPanel:
3941            "The provided script path must be a valid Streamlit script ending with '.py'." 
4042        )
4143
42-     panel_id  =  streamlit_script_path .stem 
44+     if  panel_id  ==  "" :
45+         panel_id  =  streamlit_script_path .stem 
46+ 
4347    path_str  =  str (streamlit_script_path )
4448    return  StreamlitPanel (panel_id , path_str )
4549
0 commit comments