Coloring's picture
Mirgate to ModelScope Studio 2.0
ed7ca64
Raw History Blame Contribute Delete
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()