Copy Button¶
The CopyButton
can be used to copy-paste any string value
:
Try clicking the CopyButton
above and pasting the value into your editor.
You can also provide a Pandas or Polars DataFrame
value
:
from panel_copy_paste import CopyButton
import polars as pl
dataframe = pl.DataFrame({"Hello": [1,2], "World": ["a", "b"]})
CopyButton(value=dataframe).servable()
► Run
You can also provide a callback
(function), Parameter
, or Parameterized
object:
import panel as pn
import pandas as pd
from panel_copy_paste import CopyButton
pn.extension("tabulator")
widget = pn.widgets.Tabulator(pd.DataFrame({"Hello": [1, 2], "World": ["a", "b"]}))
button = CopyButton(value=widget)
pn.Column(button, widget).servable()
► Run
If you want a custom button
, it's also possible:
import panel as pn
from panel_copy_paste import CopyButton
button = pn.widgets.Button(name="Copy Hello World", icon="copy", button_type="primary", button_style="outline")
CopyButton(value="Hello World", button=button).servable()
► Run