【Dash】feffery_antd_componenet 中的 AntdSpace

server/2024/10/20 5:36:30/

一、feffery_antd_componenet 中的 AntdSpace

feffery_antd_components(简称fac)中的AntdSpace组件是一个基于Ant Design的Dash第三方组件,它用于在水平或垂直方向上放置多个元素,并提供元素之间的间距。以下是AntdSpace组件的一些主要功能:

1、设置间距:

可以通过size属性来设置元素之间的间距,支持预设的small、middle、large三种尺寸,也可以自定义间距。

2、对齐方式:

可以设置子元素的对齐方式,通过align属性,可以设置为start、end、center、baseline。

3、自动换行:

通过wrap属性,可以设置是否自动换行,仅在水平方向上有效。

4、分隔符:

可以使用split属性来设置分隔符,例如在链接之间添加垂直分隔线。

5、紧凑模式:

AntdSpace.Compact用于表单组件之间紧凑连接且合并边框,支持的组件包括Button、AutoComplete、Cascader、DatePicker、Input、InputNumber、Select、TimePicker等。

6、垂直方向:

AntdSpace组件默认是水平方向的,但也可以设置为垂直方向,通过direction属性设置为vertical。

7、自定义尺寸:

可以通过传递一个数字给size属性来自定义间距大小。

8、预设间距:

AntdSpace组件提供了预设的间距大小,也可以通过CSS来进一步自定义样式。

二、代码

python">import dash
from dash import html
import feffery_antd_components as fac
from dash.dependencies import Output, Input, Stateapp = dash.Dash(__name__)app.layout = html.Div([fac.AntdSpace([fac.AntdDivider('AntdSpace 的应用', innerTextOrientation='center'),fac.AntdSpace([fac.AntdText('对齐方向: '),fac.AntdRadioGroup(id='space-align-input',options=['start', 'end', 'center', 'baseline'],value='start',),  # 单选按钮],size='large',)],direction='vertical',size='large',style={'width': '100%',},),fac.AntdSpace([fac.AntdText('间距大小: '),fac.AntdRadioGroup(id='space-size-input',options=['small', 'middle', 'large', '48'],value='small',  # 子容器改写默认值为 small),],size='large',   # AntdSpace设置size 默认值为 largestyle={'width': '100%',}),fac.AntdSpace(fac.AntdButton('添加 addSplitLIne 分割线', id='space-add-split-line', type='primary'),style={'padding': '5px',}),fac.AntdSpace(fac.AntdButton('添加自定义分割线', id='space-add-line', type='primary'),style={'padding': '5px',}),fac.AntdParagraph(),fac.AntdSpace(fac.AntdButton('设置元素超宽后自动换行(wrap=True)', id='space-wrap', type='primary'),style={'padding': '5px'}),fac.AntdSpace([fac.AntdSpace([fac.AntdButton(button_type, type=button_type, danger=danger)for button_type, danger in [['primary', False], ['default', False], ['dashed', False], ['text', False], ['link', False]] * 5],wrap=False,addSplitLine=True,id='space-button1',),fac.AntdSpace([fac.AntdButton(button_type, type=button_type, danger=danger)for button_type, danger in [['primary', True], ['default', True], ['dashed', True], ['text', True], ['link', True]] * 5],wrap=False,addSplitLine=True,id='space-button2',# customSplit=html.Div(#     style={'height': 30, 'borderRight': '1px dashed #8c8c8c'}# )),],direction='vertical',# id='space-button',),fac.AntdParagraph(),# 横向拓展fac.AntdSpace([html.Div(style={'backgroundColor': 'rgba(255, 255, 207, 1)','height': '20px','width': '50px',}),html.Div(style={'backgroundColor': 'rgba(250, 240, 155, 1)','height': '40px','width': '50px',}),html.Div(style={'backgroundColor': 'rgba(244, 234, 98, 1)','height': '60px','width': '50px',}),html.Div(style={'backgroundColor': 'orange','height': '80px','width': '50px',})] * 2,id='space-align-output1',align='start',  # 系统默认值也是 startsize='large',style={'backgroundColor': 'rgba(241, 241, 241, 0.8)','padding': '10px',},addSplitLine=True,),# 纵向拓展fac.AntdDivider(),fac.AntdSpace([html.Div(style={'backgroundColor': 'rgba(243, 230, 195, 1)','height': '50px','width': '20px',}),html.Div(style={'backgroundColor': 'rgba(217, 188, 154, 1)','height': '50px','width': '40px',},),html.Div(style={'backgroundColor': 'rgba(218, 158, 106, 1)','height': '50px','width': '60px',}),],id='space-align-output2',align='start',  # 系统默认值也是 startdirection='vertical',size='large',style={'backgroundColor': 'rgba(241, 241, 241, 0.8)','padding': '12px',},),]
)@app.callback([Output('space-align-output1', 'align'),Output('space-align-output2', 'align'),Output('space-button1', 'size'),Output('space-button2', 'size'),Output('space-align-output1', 'size'),Output('space-align-output2', 'size'),Output('space-button1', 'addSplitLine'),Output('space-button2', 'addSplitLine'),Output('space-align-output1', 'addSplitLine'),Output('space-button1', 'customSplit'),Output('space-button2', 'customSplit'),Output('space-button1', 'wrap'),Output('space-button2', 'wrap'),],[Input('space-align-input', 'value'),   # align 对齐方向Input('space-size-input', 'value'),    # size 间距大小Input('space-add-split-line', 'nClicks'),  # addSplitLineInput('space-add-line', 'nClicks'),Input('space-wrap', 'nClicks'),]
)
def update_space(value_align, value_size, nclick_add_split_line, nclick_add_line, nclick_wrap):if value_align:re_align = value_alignif value_size and value_size == '48':re_size = 48else:re_size = value_sizeif nclick_add_split_line and nclick_add_split_line % 2 == 1:re_app_split_line = Trueelse:re_app_split_line = Falseif nclick_add_line and nclick_add_line % 2 == 1:re_add_line = html.Div(style={'height': 30, 'borderRight': '1px dashed #8c8c8c'})else:re_add_line = Noneif nclick_wrap and nclick_wrap % 2 == 1:re_wrap = Trueelse:re_wrap = Falsereturn [re_align, re_align,re_size, re_size, re_size, re_size,re_app_split_line, re_app_split_line, re_app_split_line,re_add_line, re_add_line,re_wrap, re_wrap]if __name__ == '__main__':app.run_server(debug=True)

 

 


http://www.ppmy.cn/server/113554.html

相关文章

目标检测-YOLOv1

YOLOv1介绍 YOLOv1(You Only Look Once version 1)是一种用于目标检测的深度学习算法,由Joseph Redmon等人于2016年提出。它基于单个卷积神经网络,将目标检测任务转化为一个回归问题,通过在图像上划分网格并预测每个网…

RabbitMQ 03 在项目中的实际使用: 告警,批处理

01.例子,解耦合(使用异步) 1.1异步思想:不会专门等待 1.2 例子:程序执行 1.3 如何设计程序 多线程: 订单请求模块只用于发送请求和处理确认,订单处理模块专门用于处理请求并且发送确认信…

深入详解 C# Task.Run异步任务

目录 Task.Run Task.Run 的底层原理 默认并发数量 控制并发 使用 SemaphoreSlim 代码解析 使用 Parallel.ForEach 代码解析 注意事项 自定义任务调度器 代码解析 使用自定义任务调度器: 总结 Task.Run Task.Run 是 .NET 中创建和启动异步任务的一种便…

探寻 IP 代理地址繁多之因

在当今的网络天地里,IP 代理服务随处可见,且令人称奇的是,它们常常手握海量的 IP 地址可供挑选。那么,究竟是什么原因使得 IP 代理拥有如此众多的地址呢?现在,就让我们一同深入探究这个神秘现象背后的缘由。…

[项目][CMP][Page Cache]详细讲解

目录 1.申请内存2.释放内存3.框架 1.申请内存 当Central Cache向Page Cache申请内存时,Page Cache先检查对应位置有没有span,如果没有则向更大页寻找一个span,如果找到则分裂成两个 比如:申请的是4页page,4页page后面…

lvs DR模式调试

DS配置: # cat /etc/keepalived_docker/keepalived.conf ! Configuration File for keepalived global_defs {router_id LVS_70 # 设置lvs的id,在一个网络内应该是唯一的 }vrrp_instance VI_70 {state MASTER # 两个 DS&#xff0…

使用 macos 制作启动盘给主机安装 Windows 系统

1. 下载系统文件 微软官方地址,根据自己需要的系统版本下载对应的镜像文件即可,下载完成之后双击文件将镜像文件挂载到你的电脑,这个时候打开访达应该可以看到多了一个卷 2. 制作启动盘,并且把你的镜像复制到 U 盘 查看你的U盘…

去中心化身份(DID)与你:SOEX安全的交易未来

在快速发展的数字时代,管理和保护数字身份比以往任何时候都更加重要。去中心化身份 (DID) 已成为传统数字身份管理方法的有力替代方案,而传统方法往往存在不足。 DI&a…