File size: 1,992 Bytes
f18a2c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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 menu_click(e: gr.EventData):
    print(e._data["payload"])


with gr.Blocks() as demo:
    with ms.Application():
        with antdx.XProvider():
            with antdx.Conversations(default_active_key="item1",
                                     items=[{
                                         "key": "item1",
                                         "label": "Item1"
                                     }, {
                                         "key": "item2",
                                         "label": "Item2",
                                     }, {
                                         "key": "item3",
                                         "label": "Item3",
                                     }, {
                                         "key": "item4",
                                         "label": "Item4",
                                         "disabled": True
                                     }]) as conversations:
                with ms.Slot("menu.items"):
                    with antd.Menu.Item(label="Operation 1", key="o1"):
                        with ms.Slot("icon"):
                            antd.Icon("EditOutlined")
                    with antd.Menu.Item(label="Operation 2",
                                        key="o2",
                                        disabled=True):
                        with ms.Slot("icon"):
                            antd.Icon("StopOutlined")
                    with antd.Menu.Item(label="Operation 3",
                                        key="o3",
                                        danger=True):
                        with ms.Slot("icon"):
                            antd.Icon("DeleteOutlined")
            conversations.menu_click(fn=menu_click)

if __name__ == "__main__":
    demo.queue().launch()