pythongradio

How can I get current text from TextArea in Gradio


import gradio as gr
input1 = gr.TextArea(label="Text (100 words max)", value=example,
                                                             elem_id=f"input{i}")

I made a Text Area, and wanna get current text value from TextArea.

input1.value just returns default value that I assigned (In my case, example).

How can I get current value of TextArea?


Solution

  • If you click a button you can pass the value as an input. For example

    import gradio as gr
    input1 = gr.TextArea(label="Text (100 words max)", value=example,
                                                                 elem_id=f"input{i}")
    btn = gr.Button(value="Submit")
    btn.click(combine, inputs=[input1])
    
    def combine(input1):
        print(input1)