streamlitでdataframeをサーバーからユーザーのクリップボードにコピーする方法

調べてもほとんど出てこなかった。 こんな感じ。

$ python -m pip install bokeh
$ python -m pip instal streamlit-bokeh-events
    def copy_dataframe_button(df):
        from bokeh.models.widgets import Button
        from bokeh.models import CustomJS
        from streamlit_bokeh_events import streamlit_bokeh_events

        copy_button = Button(label="コピー")
        copy_button.js_on_event(
            "button_click",
            CustomJS(
                args=dict(df=df.to_csv(sep="\t", index=False, header=False)),
                code="""
                     navigator.clipboard.writeText(df);
                     """,
            ),
        )

        no_event = streamlit_bokeh_events(
            copy_button,
            events="GET_TEXT",
            key="get_text",
            refresh_on_update=True,
            override_height=75,
            debounce_time=0,
        )