Schluca / streamlit_tree_select

A simple and elegant checkbox tree for Streamlit.
MIT License
80 stars 9 forks source link

Is there a way to populate children of a node only when said node is expanded #9

Closed JROBOTO closed 10 months ago

JROBOTO commented 10 months ago

I'd like to start off by saying I really like this feature.

One scenario I have is the structure I want to represent with this tree can only be built up via recursive calls across a network. This is very long winded particularly since I may not need all of the nodes being retrieved. One way I would like to do it is by attaching a delegate to an attribute. Ideally this could be something I could cache so further collapse and expand interactions of the same node do not need to go back to the network.

Is something like this possible or feasible?

JROBOTO commented 10 months ago

Nevermind, I figured it out

Used st.session_state to store the tree_select component. If it exists in the session state, any expanded nodes, call the "get_children" method or whatever on those, cache the results of the "get_children" method and bobs your uncle

TL;DR lack of talent for easily confused developer