Spaces:
Running
Running
File size: 2,299 Bytes
46a58e8 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
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.Item(key="retry", label="Retry"):
with ms.Slot("icon"):
antd.Icon("RedoOutlined")
with antdx.Actions.Item(key="copy", label="Copy"):
with ms.Slot("icon"):
antd.Icon("CopyOutlined")
antd.Divider("More Menu Items")
with antdx.Actions() as actions2:
with antdx.Actions.Item(key="retry", label="Retry"):
with ms.Slot("icon"):
antd.Icon("RedoOutlined")
with antdx.Actions.Item(key="copy", label="Copy"):
with ms.Slot("icon"):
antd.Icon("CopyOutlined")
with antdx.Actions.Item(key="more"):
with antdx.Actions.Item(key="share", label="Share"):
with ms.Slot("icon"):
antd.Icon("ShareAltOutlined")
antdx.Actions.Item(key="qq", label="QQ")
antdx.Actions.Item(key="wechat", label="WeChat")
antdx.Actions.Item(key="import", label="Import")
with antdx.Actions.Item(
key="delete", label="Delete",
danger=True) as actions_delete_item:
with ms.Slot("icon"):
antd.Icon("DeleteOutlined")
with antdx.Actions.Item(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()
|