File size: 1,475 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
import gradio as gr
import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

default_placement = 'right'

with gr.Blocks() as demo:
    with ms.Application():
        with antd.ConfigProvider():
            with antd.Space():
                placement = antd.RadioGroup(
                    options=["top", "bottom", "left", "right"],
                    value=default_placement)
                btn = antd.Button("Open Drawer", type="primary")
            with antd.Drawer(open=False,
                             title="Drawer with extra actions",
                             width=500) as drawer:
                with ms.Slot("extra"):
                    with antd.Space():
                        cancel_btn = antd.Button("Cancel")
                        ok_btn = antd.Button("OK", type="primary")
                antd.Typography.Paragraph("Some contents...")
                antd.Typography.Paragraph("Some contents...")
                antd.Typography.Paragraph("Some contents...")
            placement.change(fn=lambda p: gr.update(placement=p),
                             inputs=[placement],
                             outputs=[drawer])
            btn.click(fn=lambda: gr.update(open=True), outputs=[drawer])

            gr.on([drawer.close, ok_btn.click, cancel_btn.click],
                  fn=lambda: gr.update(open=False),
                  outputs=[drawer])

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