Hi all!
I have a requirement where I have to keep two data editors synced up for graphing (in the full application, this is a summary table and a broken out table for one of our categories).
I’m running into an issue where the table flickers every time the dataframe gets updated on the backend. This is an issue mainly because it resets the sort which is frustrating from a user experience.
It seems similar to these issues previously reported:
However, the suggestion in the first issue to make the change in-place did not work for me and the second issue was solved privately (if it was indeed solved). I’ve also tested this with Pandas (just by crudely replacing polars with pandas in the import statement) and got the same issue.
Any thoughts on how to resolve this? Been poking it at it for a couple programming sessions now.
Minimum reproducible:
#python version==3.12.0
import streamlit as st #== 1.41.1
import polars as pl #==1.19.0
class StateManager():
def __init__(self):
self.df1 = pl.DataFrame({"show": [True, False, True], "metadata": [4, 5, 6]})
self.df2 = pl.DataFrame({"show": [True, False, True], "metadata": [4, 5, 6]})
def sync_tables(self):
changes = st.session_state["t1changes"]['edited_rows']
for change in changes:
new_state = changes[change]['show']
self.df2[change, "show"] = new_state
if not st.session_state.get("statemanager"):
st.session_state["statemanager"] = StateManager()
st.data_editor(st.session_state["statemanager"].df1, key="t1changes",
on_change=st.session_state["statemanager"].sync_tables,
disabled=("metadata"))
st.data_editor(st.session_state["statemanager"].df2, key="t2changes",
disabled=("show", "metadata"))