Spaces:
Running
Running
File size: 672 Bytes
ba4a662 afb453a 1969c22 ba4a662 afb453a ba4a662 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import gradio as gr
import modelscope_studio.components.base as ms
import modelscope_studio.components.legacy 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, ms.Application():
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()
|