ChrisDelClea / streamlit-agraph

A Streamlit Graph Vis
MIT License
387 stars 52 forks source link

Default values in ConfigBuilder #55

Closed huwilerb closed 4 months ago

huwilerb commented 5 months ago

Topic:

ConfigBuilder instantiation

Descirption

The class ConfigBuilder don't use it's **kwargs parameter. it would be very useful if we can pass arguments such as height or width when creating an instance of ConfigBuilder , and use these arguments for Config and as default value for the streamlit sidebar

Implementation example:

    def __init__(self, nodes=None, edges=None, **kwargs):
        self.config = Config(**kwargs)
        self.kwargs = {}
        self.nodes = nodes
        st.sidebar.write("Agraph Configurations")
        self.basic_widget = self.basic_widget()
        self.physics_widget = self.physics_widget()
        self.hierarchical_widget = self.hierarchical_widget()
        self.groups = self.group_widget()

    def basic_widget(self):
        basic_expander = st.sidebar.expander("Basic Config", expanded=True)
        with basic_expander:
            basic_expander.number_input("height", value=getattr(self.config, "height", 750) , key="height")
            basic_expander.number_input("width", value=getattr(self.config, "width", 750) , key="width")
            basic_expander.checkbox("directed", value=getattr(self.config, "height", True) , key="directed")
            self.kwargs["height"] = st.session_state.height
            self.kwargs["width"] = st.session_state.width
            self.kwargs["directed"] = st.session_state.directed
huwilerb commented 5 months ago

I will try to write the code for an implementation in the direction of the example I gave a make a pull request

ChrisDelClea commented 4 months ago

great, thank you.