I have downloaded the Streamlit Tree Select, a straightforward and elegant checkbox tree component from the following link: New Component: streamlit-tree-select, a simple and elegant checkbox tree.
The code functions perfectly; however, I require assistance in saving the selected data to a DataFrame and displaying the value of the selected tree item or node in a text box. I would appreciate it if you could provide me with the appropriate code to meet both of these requirements.
code is below
#New Component: streamlit-tree-select, a simple and elegant checkbox tree - #15 by bkcollection
#GitHub - Schluca/streamlit_tree_select: A simple and elegant checkbox tree for Streamlit.
import streamlit as st
from streamlit_tree_select import tree_select
import pandas as pd
st.title(“ Streamlit-tree-select”)
st.subheader(“A simple and elegant checkbox tree for Streamlit.”)
Create nodes to display
nodes = [
{“label”: “Folder A”, “value”: “folder_a”},
{
“label”: “Folder B”,
“value”: “folder_b”,
“children”: [
{“label”: “Sub-folder A”, “value”: “sub_a”},
{“label”: “Sub-folder B”, “value”: “sub_b”},
{“label”: “Sub-folder C”, “value”: “sub_c”},
],
},
{
“label”: “Folder C”,
“value”: “folder_c”,
“children”: [
{“label”: “Sub-folder D”, “value”: “sub_d”},
{
“label”: “Sub-folder E”,
“value”: “sub_e”,
“children”: [
{“label”: “Sub-sub-folder A”, “value”: “sub_sub_a”},
{“label”: “Sub-sub-folder B”, “value”: “sub_sub_b”},
],
},
{“label”: “Sub-folder F”, “value”: “sub_f”},
],
},
]
df1 = pd.DataFrame(nodes)
return_select = tree_select(nodes)
st.write(return_select)
st.write(df1)