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

with gr.Blocks() as demo:
    with ms.Application():
        with antd.ConfigProvider():
            with antd.Flex(gap="middle", align="start", vertical=True):
                ms.Div("Select justify:")
                justify_segmented = antd.Segmented('flex-start',
                                                   options=[
                                                       'flex-start',
                                                       'center',
                                                       'flex-end',
                                                       'space-between',
                                                       'space-around',
                                                       'space-evenly',
                                                   ])
                ms.Div("Select align:")
                align_segmented = antd.Segmented(
                    'flex-start', options=['flex-start', 'center', 'flex-end'])
                with antd.Flex(elem_style=dict(
                        width='100%',
                        height=120,
                        borderRadius=6,
                        border='1px solid #40a9ff',
                ),
                               justify="flex-start",
                               align="flex-start") as flex:
                    antd.Button("Primary", type="primary")
                    antd.Button("Primary", type="primary")
                    antd.Button("Primary", type="primary")
                    antd.Button("Primary", type="primary")
                justify_segmented.change(fn=lambda _justify_segmented: gr.
                                         update(justify=_justify_segmented),
                                         inputs=[justify_segmented],
                                         outputs=[flex])
                align_segmented.change(fn=lambda _align_segmented: gr.update(
                    align=_align_segmented),
                                       inputs=[align_segmented],
                                       outputs=[flex])

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