File size: 1,173 Bytes
0bd62e5
1
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: render_split"]}, {"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", "with gr.Blocks() as demo:\n", "    input_text = gr.Textbox(label=\"input\")\n", "    mode = gr.Radio([\"textbox\", \"button\"], value=\"textbox\")\n", "\n", "    @gr.render(inputs=[input_text, mode], triggers=[input_text.submit])\n", "    def show_split(text, mode):\n", "        if len(text) == 0:\n", "            gr.Markdown(\"## No Input Provided\")\n", "        else:\n", "            for letter in text:\n", "                if mode == \"textbox\":\n", "                    gr.Textbox(letter)\n", "                else:\n", "                    gr.Button(letter)\n", "\n", "if __name__ == \"__main__\":\n", "    demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}