Just to focus in on the session_state.txt case:
- You’re only populating it IF window is not set
- If window is set, it doesn’t get populated
- You are also putting it as the
key
of a widget - If that widget disappears, that key will be removed from session state automatically. (this behavior can be annoying, though there are some good reasons for it. We are looking into options for making keys persist even if widgets are gone, since that is nice in some cases).
That #4 is most of the issue you are experiencing, I believe.
There is a hack to get around this, which is to explicitly set the session state. It’s weird, but it works.
for k, v in st.session_state.items():
st.session_state[k] = v
If you add this at the bottom of your “change window” calback, then the problem goes away.