Spaces:
Runtime error
Runtime error
Download components/Lifecycle/demos/basic.py from K00B404/scope-studio: direct link, hf CLI and curl.
- Browser
- Download file 590 Bytes
-
https://huggingface.co/spaces/K00B404/scope-studio/resolve/main/components/Lifecycle/demos/basic.py
- Command line
-
hf download hf://spaces/K00B404/scope-studio/components/Lifecycle/demos/basic.py
-
curl -L -o basic.py https://huggingface.co/spaces/K00B404/scope-studio/resolve/main/components/Lifecycle/demos/basic.py
590 Bytes
| import gradio as gr | |
| import modelscope_studio as mgr | |
| def mount(e: gr.EventData): | |
| # current page state | |
| print("onMount", e._data) | |
| def resize(e: gr.EventData): | |
| print("onResize", e._data) | |
| def onUnmount(e: gr.EventData): | |
| print("onUnmount", e._data) | |
| with gr.Blocks() as demo: | |
| gr.Markdown("The Lifecycle component will not be rendered on the page.") | |
| lifecycle = mgr.Lifecycle() | |
| # listen to the page lifecycle | |
| lifecycle.mount(fn=mount) | |
| lifecycle.resize(fn=resize) | |
| lifecycle.unmount(fn=onUnmount) | |
| if __name__ == "__main__": | |
| demo.queue().launch() | |