gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.38k stars 2.52k forks source link

Add possibility to show copy button to gr.Dataframe #6981

Open mireiarmirapeix opened 9 months ago

mireiarmirapeix commented 9 months ago

Is your feature request related to a problem? Please describe.
I am building an app that returns tabular data. I am able to display the output as a gr.Dataframe() but there's no way to add a copy button to it (nor to easily select and copy the data manually). I have tried displaying the data as gr.Markdown() which allows me to select and copy manually, but it doesn't allow for a copy button either.

Describe the solution you'd like
The possibility to add a copy button to Dataframes and Markdowns.

Additional context
Add any other context or screenshots about the feature request here.

pngwn commented 8 months ago

We need to figure out where to put buttons like these. I think we need to adjust the design of the dataframe in order to add a small 'toolbar' or icon bar. This would solve a number of issues and offer a clearer path forwards for some of the other feature requests we have had.

mberco-quandl commented 6 months ago

@abidlabs +1 Stumbled on this thread while looking for a workaround to the lack of ability to write dataframes into Gradio's file handling system as a csv https://github.com/gradio-app/gradio/issues/8098#issuecomment-2072370094. Currently I write the dataframe to my working directory as a temp file, then I pass the full path of the temp file into the Gradio File object, then use an upload event handler to delete the temp file in the working directory. In this way I can rely on delete_cache to semi-safely manage storage, however there is a risk of my working directory getting polluted if a tempfile is not deleted. If a user could copy-paste an entire Gradio Dataframe's contents into memory they could simply paste it into an open spreadsheet. Even better would be a button triggering something like Flask's send_file that would trigger a download directly from Dataframe in server memory to client as csv.