Spaces:
Running
Running
Download components/base/application/demos/custom_event.py from modelscope/modelscope-studio: direct link, hf CLI and curl.
- Browser
- Download file 499 Bytes
-
https://huggingface.co/spaces/modelscope/modelscope-studio/resolve/main/components/base/application/demos/custom_event.py
- Command line
-
hf download hf://spaces/modelscope/modelscope-studio/components/base/application/demos/custom_event.py
-
curl -L -o custom_event.py https://huggingface.co/spaces/modelscope/modelscope-studio/resolve/main/components/base/application/demos/custom_event.py
499 Bytes
| import gradio as gr | |
| import modelscope_studio.components.antd as antd | |
| import modelscope_studio.components.base as ms | |
| def on_custom(e: gr.EventData): | |
| print(e._data) | |
| with gr.Blocks() as demo: | |
| with ms.Application() as app: | |
| with antd.ConfigProvider(): | |
| gr.HTML( | |
| """<button onclick="window.ms_globals.dispatch({type: 'custom', data: 'test'})">Click me</button>""" | |
| ) | |
| app.custom(on_custom) | |
| if __name__ == "__main__": | |
| demo.queue().launch() | |