File size: 1,961 Bytes
e841ba5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
import gradio as gr
import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms


def info():
    return gr.update(visible=True,
                     type="info",
                     message="Info Notification Message",
                     description="This is a info description.",
                     placement="topLeft",
                     key="info")


def success():
    return gr.update(visible=True,
                     type="success",
                     message="Success Notification Message",
                     description="This is a success description.",
                     placement="topRight",
                     key="success")


def error():
    return gr.update(visible=True,
                     type="error",
                     message="Error Notification Message",
                     description="This is an error description.",
                     placement="bottomLeft",
                     key="error")


def warning():
    return gr.update(visible=True,
                     type="warning",
                     message="Warning Notification Message",
                     description="This is a warning description.",
                     placement="bottomRight",
                     key="warning")


with gr.Blocks() as demo:
    with ms.Application():
        with antd.ConfigProvider():
            with antd.Space():
                info_btn = antd.Button("Info")
                success_btn = antd.Button("Success")
                error_btn = antd.Button("Error")
                warning_btn = antd.Button("Warning")

            notification = antd.Notification(visible=False)
            info_btn.click(info, outputs=[notification])
            success_btn.click(success, outputs=[notification])
            error_btn.click(error, outputs=[notification])
            warning_btn.click(warning, outputs=[notification])

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