Update dynamic values based on slider output to a table

My use case is to create a table which initally has some static values filled but based on few input parameters from the slider the values in the table should change dynamically.

Also I have another usecase looking forward to be implemented. Can we have some kind of customizable text boxes or flash-cards kind of a thing where we can dynamically change the inputs?

Hi saikrupa,

Perhaps this thread can help:

It is about filtering based on sliders, not changing table values, but the basic idea is the same.

Depending on your usecase, you may also need to look into session state (see e.g. Multi-page app with session state) for saving the changes you make to the table.

For the second part of your question, streamlit does have text boxes, but I do not know if they meet your needs, you will have to be slightly more specific about what you are envisioning. See API Reference - Streamlit Docs

Let me know if it helps or if you have further questions! :slight_smile:

2 Likes

Yes so basically second part of my question is - I wanted to have a text box - not an input box where the values inside the box change based on the slider value . Nothing is input from the user. Jst a rectangular text box inside which I can add sliders and text representing some values related to that slider. Is that possible?

Ah, I see. I think I understand what you mean.

Here is a minimal example:

import streamlit as st

text_length = st.slider("Choose text length", min_value=1, max_value=10, step=1)
full_text = 'abcdefghij'
output_text = full_text[:text_length]

st.markdown(output_text) 

And then you can style your text using markdown (see https://docs.streamlit.io/en/latest/api.html#display-text) or even HTML+CSS (kind of hacky, see Colored boxes around sections of a sentence for inspiration). In this way, you can also for example add a rectangular box around the text.

Hope it helps!

1 Like