Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| ''' | |
| https://blog.csdn.net/DreamingBetter/article/details/123854496 | |
| https://blog.51cto.com/u_15485092/6223566 | |
| ''' | |
| def txt_output(txt_in): | |
| return txt_in | |
| with gr.Blocks() as demo: | |
| output_str = "" | |
| with gr.Row(): | |
| shot_select = gr.Dropdown(label="景别 远中近",type="value",choices=["广", "远"]) | |
| cam_select = gr.Dropdown(label="机位 俯仰角度",choices=("仰", "俯")) | |
| special_select = gr.CheckboxGroup(label="画面效果",choices=("失真","模糊","聚焦")) | |
| body_select = gr.inputs.Radio(['全身','半身'],label="半全身") | |
| with gr.Row(): | |
| txt_cn_in = gr.inputs.Textbox(label="输入中文") | |
| btn_cn = gr.Button("中>>英") | |
| txt_en_in = gr.Text(interactive=True) | |
| btn_cn.click(fn=txt_output, inputs=txt_cn_in, outputs=txt_en_in) | |
| with gr.Row(): | |
| txt_en_in = gr.inputs.Textbox(label="输入英文") | |
| btn_en = gr.Button("英>>中") | |
| txt_en_out = gr.Text(label="result", interactive=True) | |
| btn_en.click(fn=txt_output, inputs=txt_en_in, outputs=txt_en_out) | |
| demo.launch() | |
| import gradio as gr | |
| def welcome(name): | |
| t = type(name) | |
| return f"{t}" | |
| with gr.Blocks() as demo: | |
| gr.Markdown( | |
| """ | |
| # Hello World! | |
| Start typing below to see the output. | |
| """) | |
| with gr.Row(): | |
| shot_select = gr.Dropdown(label="景别 远中近",type="value",choices=["广", "远"]) | |
| inp = shot_select | |
| out = gr.Textbox() | |
| #设置change事件 | |
| inp.change(fn = welcome, inputs = inp, outputs = out) | |
| demo.launch() | |