I have a following class that renders some content to the page. All the content I write to the page is held inside an st.empty container within the class. I want to create a button that will a) delete the old content and b) regenerate new content. When I try to achieve this with the following code where the button callback is called to clear the value, it doesnt empty the value but it does generate the new topics:
In my mind, both these code snippets should be equivalent no? (FYI: the empty method call is something I implemented to remove all attached streamlit.components from my container class)
I donāt have your TopicGeneration function to test this out myself, but there is a bit of a bug with st.empty where the backend seems to move ahead faster than the frontend can keep up. If you add time.sleep(.2) immediately after calling the .empty() method, does that change the behavior in the first snippet?
Nope, the old content is still hanging around. Went as far as setting the sleep to 1.0, no difference. Which in my mind doesnāt feel like some racy bug where the empty fails to update the state before the re-render loop, think something is just fundamentally not working with the callbacks? In general, albeit in my very extensive streamlit usage of grand 2 days, Iāve found that when Streamlit state modification within the main scope works as expected but when state mod move into function scopes ie. into functions, things become a little fcky, as per described here as well: Buttons Within a Class Don't Trigger When a Key is Added
Could you post a complete, executable example please? Any simplification to demonstrate just the part that isnāt working as expected would be helpful. Iām trying to stitch together what youāve posted here and on the new thread, but itās still incomplete so I donāt have anything to execute yet.