File size: 1,315 Bytes
f719f9d
1
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: copy_events"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "md = \"This is **bold** text.\"\n", "\n", "def copy_callback(copy_data: gr.CopyData):\n", "    return copy_data.value\n", "\n", "with gr.Blocks() as demo:\n", "    textbox = gr.Textbox(label=\"Copied text\")\n", "    with gr.Row():\n", "        markdown = gr.Markdown(value=md, header_links=True, height=400, show_copy_button=True)\n", "        chatbot = gr.Chatbot([(\"Hello\", \"World\"), (\"Goodbye\", \"World\")], show_copy_button=True)\n", "        textbox2 = gr.Textbox(\"Write something here\", interactive=True, show_copy_button=True)\n", "\n", "        gr.on(\n", "            [markdown.copy, chatbot.copy, textbox2.copy],\n", "            copy_callback,\n", "            outputs=textbox\n", "        )\n", "\n", "if __name__ == \"__main__\":\n", "    demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}