Updating a Python dictionary from text_input values

Summary

I have an app that takes bunch of values from a list of dictionaries that have nested objects withing themselves. So I’m trying to use the on_change callback in the text_input fields to update the values of my frame_data dictionary.

Steps to reproduce

Code snippet:

for frame in frame_data:

    frame_count += 1

    sidebar.button(
        f"Remove Frame {frame_count}",
    )

    EX = st.expander(f"Frame: {frame_count}")

    EX.image(f"previews/frame_{frame_count}.png", width=400)
    EX.text_input(
        "frame_label",
        value=frame["frame_label"],
        key=uuid.uuid1(),
    )
    EX.text_input("frame_duration", value=frame["frame_duration"], key=uuid.uuid1(),on_change=update_data())
    EX.text_input("frame_start", value=frame["frame_start"], key=uuid.uuid1())
    EX.text_input("frame_end", value=frame["frame_end"], key=uuid.uuid1())

    for item in frame["video"]:
        EX.text_input("video_file_path", value=item["file_path"], key=uuid.uuid1())
        EX.text_input("video_start", value=item["start"], key=uuid.uuid1())
        EX.text_input("video_end", value=item["end"], key=uuid.uuid1())
        EX.checkbox("has_audio", value=item["has_audio"], key=uuid.uuid1())

    
    for item in frame["content"]:

        EX.checkbox("disable", value=item["disable"], key=uuid.uuid1())
        if item["disable"] == False:

            if item["type"] == "text":
                EX.subheader("Text options")
                EX.text_input("data", value=item["data"], key=uuid.uuid1())
            if item["type"] == "image":
                EX.subheader("Image options")
                EX.text_input("width", value=item["width"], key=uuid.uuid1())
                EX.text_input("height", value=item["height"], key=uuid.uuid1())

            EX.text_input("position x", value=item["position"]["x"], key=uuid.uuid1())
            EX.text_input("position y", value=item["position"]["y"], key=uuid.uuid1())

            EX.text_input("type", value=item["type"], key=uuid.uuid1())

        else:

            EX.warning(f"{item['type']}: Disabled")

Expected behavior:

EX.text_input(“frame_start”, value=frame[“frame_start”], key=uuid.uuid1(), on_change=“update_data(frame[‘frame_start’])”)

I expect it to take the updated value from my inputfield in the browser and update the values in frame_data

Actual behavior:

Either nothing happens, or the value data gets rewritten by the loop.

  • Streamlit version: (1.16.0)
  • Python version: (3.11)
  • Using PipEnv
  • OS version: MacOS Ventura
  • Browser version: Firefox Developer