File size: 2,376 Bytes
46a58e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed7ca64
46a58e8
 
ed7ca64
 
 
 
46a58e8
ed7ca64
46a58e8
 
ed7ca64
46a58e8
 
ed7ca64
 
 
 
 
 
 
 
 
 
 
 
 
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.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()