|
import gradio as gr |
|
|
|
def welcome(name,btn): |
|
|
|
js_code = "<script>alert('Button clicked!');</script>" |
|
response = f"Hello! Click the button below:<br><button onclick=\"{js_code}\">Click Me</button>" |
|
|
|
return "response" |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown( |
|
""" |
|
# Hello World! |
|
Start typing below to see the output. |
|
""") |
|
inp = gr.Textbox(placeholder="What is your name?") |
|
out = gr.Textbox() |
|
btn = gr.Button("1") |
|
def changeIcon(btnw): |
|
|
|
return "tt",gr.update(value="", interactive=True) |
|
inp.change(welcome, [inp,btn], btn).then(changeIcon,btn,btn) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|
|
|