mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
19 lines
573 B
Python
19 lines
573 B
Python
import gradio as gr
|
|
|
|
def change_textbox(choice):
|
|
if choice == "short":
|
|
return gr.update(lines=2, visible=True, value="Short story: ")
|
|
elif choice == "long":
|
|
return gr.update(lines=8, visible=True, value="Long story...")
|
|
else:
|
|
return gr.update(visible=False)
|
|
|
|
with gr.Blocks() as demo:
|
|
radio = gr.Radio(
|
|
["short", "long", "none"], label="Essay Length to Write?"
|
|
)
|
|
text = gr.Textbox(lines=2, interactive=True)
|
|
radio.change(fn=change_textbox, inputs=radio, outputs=text)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch() |