Spaces:
Running
Running
Download components/antdx/actions/demos/basic.py from modelscope/modelscope-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.38 kB
-
https://huggingface.co/spaces/modelscope/modelscope-studio/resolve/main/components/antdx/actions/demos/basic.py
- Command line
-
hf download hf://spaces/modelscope/modelscope-studio/components/antdx/actions/demos/basic.py
-
curl -L -o basic.py https://huggingface.co/spaces/modelscope/modelscope-studio/resolve/main/components/antdx/actions/demos/basic.py
2.38 kB
| import gradio as gr | |
| import modelscope_studio.components.antd as antd | |
| import modelscope_studio.components.antdx as antdx | |
| import modelscope_studio.components.base as ms | |
| def on_click(e: gr.EventData): | |
| keyPath = ','.join(e._data["payload"][0]["keyPath"]) | |
| key = e._data["payload"][0]["key"] | |
| gr.Info('keyPath: ' + keyPath + ', key: ' + key) | |
| def on_delete(): | |
| gr.Success("Delete success") | |
| with gr.Blocks() as demo: | |
| with ms.Application(): | |
| with antdx.XProvider(): | |
| with antdx.Actions() as actions: | |
| with antdx.Actions.ActionItem(key="retry", label="Retry"): | |
| with ms.Slot("icon"): | |
| antd.Icon("RedoOutlined") | |
| with antdx.Actions.ActionItem(key="copy", label="Copy"): | |
| with ms.Slot("actionRender"): | |
| antdx.Actions.Copy(text="Copy Text") | |
| antd.Divider("More Menu ActionItems") | |
| with antdx.Actions() as actions2: | |
| with antdx.Actions.ActionItem(key="retry", label="Retry"): | |
| with ms.Slot("icon"): | |
| antd.Icon("RedoOutlined") | |
| with antdx.Actions.ActionItem(key="copy", label="Copy"): | |
| with ms.Slot("icon"): | |
| antd.Icon("CopyOutlined") | |
| with antdx.Actions.ActionItem(key="more"): | |
| with ms.Slot("subItems"): | |
| with antdx.Actions.ActionItem(key="share", | |
| label="Share"): | |
| with ms.Slot("icon"): | |
| antd.Icon("ShareAltOutlined") | |
| antdx.Actions.ActionItem(key="import", label="Import") | |
| with antdx.Actions.ActionItem( | |
| key="delete", label="Delete", | |
| danger=True) as actions_delete_item: | |
| with ms.Slot("icon"): | |
| antd.Icon("DeleteOutlined") | |
| with antdx.Actions.ActionItem(key="clear", label="Clear"): | |
| with ms.Slot("icon"): | |
| antd.Icon("ClearOutlined") | |
| actions.click(fn=on_click) | |
| actions2.click(fn=on_click) | |
| actions_delete_item.item_click(fn=on_delete) | |
| if __name__ == "__main__": | |
| demo.queue().launch() | |