CopyToClip#
Overview#
CopyToClip is a custom textField that provides a handy copy-to-clipboard javascript behaviour. When the clipboard btn is clicked the v_model will be copied in the local browser clipboard. You just have to change the clipboard v_model before displaying it to the end user to have a custom value. When copied, the icon change from a copy to a check.
Any argument from the original TextField ipyvuetify class can be used to complement it.
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
clip = sw.CopyToClip(v_model="toto")
clip
/home/docs/checkouts/readthedocs.org/user_builds/sepal-ui/envs/latest/lib/python3.10/site-packages/google/api_core/_python_version_support.py:273: FutureWarning: You are using a Python version (3.10.19) which Google will stop supporting in new releases of google.api_core once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.api_core past that date. warnings.warn(message, FutureWarning)
You can also dynamically change the v_model value.
Note
The TextField widget is in readonly mode to aoid modifications from the end user.
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
clip = sw.CopyToClip()
clip.v_model = "toto"
clip
Note
More information can be found here.