File size: 2,127 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
48
49
50
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 active_change(e: gr.EventData):
    print(e._data["payload"])


with gr.Blocks() as demo:
    with ms.Application():
        with antdx.XProvider():
            conversations1 = 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
                                                 }])

            antd.Divider("Customized Item")

            with antdx.Conversations(
                    default_active_key="item1") as conversations2:
                with antdx.Conversations.Item(key="item1"):
                    with ms.Slot("label"):
                        antd.Typography.Text("Item1", type="success")
                    with ms.Slot("icon"):
                        antd.Icon()

                with antdx.Conversations.Item(key="item2"):
                    with ms.Slot("label"):
                        antd.Typography.Text("Item2", type="success")
                    with ms.Slot("icon"):
                        antd.Icon()
            conversations1.active_change(fn=active_change)
            conversations2.active_change(fn=active_change)

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