How to disable copying cells from the new st.dataframe?

Is there any way of stopping users from easily copying and pasting cells from the new version of st.dataframe? I’m aware it’s impossible to truly prevent this, it just needs to be more difficult than it currently is.

In Streamlit 1.9.2 I was able to accomplish this by disabling selection with CSS like so:

disable_df_selection_css = """
  <style>
      div[role="grid"] div {user-select: none;}
  </style>
  """
markdown(disable_df_selection_css, unsafe_allow_html=True)

This no longer works with the new st.dataframe, even after some trial and error with different CSS selectors. My assumption at this point is that glide-data-grid doesn’t respect user-select, so I’m not sure if this is still possible. Is there any way of disabling just copying, if not selection?

Hey @ThomasNickerson,
Unfortunatly, it is currently not possible to disable the copy to clipboard with the new dataframe. CSS hacks will also not work since the new dataframe uses HTML Canvas instead of HTML DOM. The old dataframe UI is still accessible via either: st._legacy_dataframe or st.table.

What is your usecase for disabling the copy-to-clipboard? Is it related to data privacy/security concerns?

Thanks @lukasmasuch, I figured as much, just wanted to make sure.

And yes, that’s essentially the usecase, although it’s not related to any concrete regulatory or compliance requirements. The dataframe in question has proprietary information in it so the client wanted to make it harder to copy directly into an Excel sheet or similar.