st.code is said to be just a wrapper for st.markdown. Looking at st.code code it is not clear how the “copy to clipboard” icon appears in the box that wraps around the body provided to st.code. How can I decode that?
If that can be understood, one could replace that symbol more visibly by something like “Copy Me”. I have been trying to do something like that with st.button and various suggested libraries. I can do it locally, but it hasn’t worked on deployed apps. I did follow the answers elsewhere and populated requirements.txt and packages.txt with all kinds of things, but to no avail.
Not having looked at the source code, the copy-to-clipboard icon is almost certainly a function of the underlying JavaScript markdown library we’re using. What are you trying to solve for here?
If it is JavaScript markdown, that may not help here.
What I was trying to do is to implement a copy-to-clipboard button. Despite using various suggested combinations of pyperclip, clipboard, xerox python libraries in requirements.txt along with xsel etc. in packages.txt, I kept on getting “no copy/paste mechanism” when deploying (it worked fine locally). I know that others have had success with this, but I haven’t seen something like “do exactly this”. And these always used external libraries.
Since st.code does it so trivially, but always showing the copy symbol after one hovers, I was wondering if one could copy whatever part of the st.code (or the code that it depends on) is responsible for that to ones own program and modify to get the needed functionality …
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.